A Spanish naval expedition under the command of the Genoese condottiero and admiral Andrea Doria and the Spaniard Bernardino de Mendoza, supported by the Knights of Malta under their Grand Master Claude de la Sengle, besieged and captured the Ottoman stronghold of Mahdia or Mahdiye, defended by the Ottoman Admiral Turgut Reis, known as Dragut, who was using the place as a base for his piratical activities throughout the Spanish and Italian coasts.
In 1550 the Hafsid kingdom of Tunis, which stretched from the east of modern Algeria to the west of modern Libya, was mired in anarchy, ruled by a council of chieftains that fought each other and none of whom recognized the authority of the Sultan of Tunis, Abu al-Abbas Ahmad III, who had deposed and blinded his father Hasan, a protégé of the Emperor Charles V.[4] In the spring of 1550, taking advantage of the situation, the Ottoman admiral Turgut Reis, with the aid of one of the local leaders, took control of the coastal town of Mahdia,[4] located atop a rock advanced into the sea and defended by two circles of walls with towers and a citadel encircled by a moat.
[6] Fearing that the town would become a base for the Barbary corsairs, which threatened the Christian shipping in the Western Mediterranean, the Holy Roman Emperor Charles V, supported by the Papacy and the Knights of Malta, decided to organize an expedition to capture the city.
[7] Within hours the Ottoman infantry and cavalry were driven out of a hill they occupied, and to the next day the city was completely surrounded by trenches dug six hundred meters from the walls.
[7] Despite advancing the artillery close to the walls and improving the trenches, the besiegers, harassed continuously by sallies of the Ottoman garrison, did not make significant progresses in the following days.
After being repelled by the inhabitants of Alzira, Sueca, and other villages, the Ottoman admiral sailed along the Barbary Coast calling for help and money to pay an army to relief Mahdia.
[7] The Bey of Tunis and the chieftain of Caruan refused to help him, but he managed to assemble a force composed of 3,700 Moors, 800 Turks, and 60 sipahis, which his fleet disembarked near Mahdia under cover of night.
It was García Álvarez de Toledo, 4th Marquis of Villafranca, who had the idea of bombing the walls from the sea, forming a gun battery on two galleys previously deforested and united to each other with hangers and planks.