Capture of Mahdiye ( 1550 ) The capture of Mahdia took place between June and September of 1550 during the Ottoman - Habsburg struggle for the control of the Mediterranean when a large Spanish expedition under the command of the Genoese condottiero Andrea Doria and the Spaniard Bernardino de Mendoza , supported by the Knights of Malta under his Grand Master Claude de la Sengle , besieged and captured the stronghold of Mahdia or Mahdiye , defended by the Ottoman Admiral Turgut Reis , who used it as a base for his piratical activities throughout the Spanish and Italian coasts . Mahdia was abandoned by Spain three years after its capture , being destroyed all its fortifications . Background . In 1550 the Hafsid kingdom was mired in anarchy , ruled by a council of chiefs facing each other , none of whom recognized the authority of the King of Tunis , Hamid , who had deposed and blinded his father Hasan , a protégé of the Emperor Charles V . In the spring of 1550 , taking advantage of this situation , the Ottoman admiral Turgut Reis , with the aid of one of the local leaders , took control of the coastal town of Mahdia , located atop a rock advanced in the sea and defended by two circles of walls , towers and a citadel encircled by a moat . In 1546 Turgut Reis , also known as Dragut , had organized a fleet of 25 brig s with which he harassed the Calabrian and Neapolitan coasts as part of the campaign that culminated in the capture of Mahdia . For this reason , fearing that the town became a base for pirates who threaten the Christian shipping in the Western Mediterranean , Charles V , supported by the Papacy and the Knights of Malta , decided to organize an expedition to take the city . This expedition would be commanded by the Genoese admiral Andrea Doria and the Spanish commander Bernardino de Mendoza , Captain General of the galleys of Spain , and would consist of a force of 52 galley s and 28 naos carrying Captain General Juan de la Vega ’ s land troops and besieging material provided by de la Vega himself , who was Viceroy of Sicily , and the Viceroy of Naples . Expedition . Siege . The Spanish fleet set sail to Mahdia on 24 June and arrived there four days later . The city was defended by the nephew of Turgut Reis , Hesar , who had spent two months locking cattle and storing rice and beans for a year , in anticipation of being under siege . The landing of the Spanish troops took place under the protection of the galleys and out of Mahdia ' s gun reach . 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 trench es dug six hundred meters from the walls . Luis Pérez de Vargas , mayor of La Goulette , who was in command of the Spanish artillery , ordered to install several pieces of heavy artillery on the hill occupied the previous day to cover the location of the 18 lighter pieces that had disposed to beat the walls . That same day was launched the first assault , which failed because the moat were not even full . Despite advance the artillery and improve the trenches , the besiegers , continually harassed by sallies of the Ottoman garrison , did not made significant progresses in the following days . Ottoman relief . Turgut Reis received news of the siege while he was plundering the coast of Valencia . After being finally defeated by the inhabitants of Alcira , Sueca and other villages , the Ottoman admiral sailed along the Barbary Coast calling for help and money to pay an army to relief Mahdia . The Bey of Tunis and the chief of Caruan refused to help him , but he managed to assemble a force composed by 3 , 700 Moors , 800 Turkish and 60 sipahi s , which his fleet disembarked near Mahdia under cover of night . He also sent a swimmer who circumvented the Spanish blockade and entered into Mahdia to inform governor Hesar . At dawn on 25 July , Turgut Reis ' s troops , hidden in an olive grove , attacked the Spanish along with Mahdia ' s garrison , which made an unexpected sallie . They managed to penetrate the trenches and the besieging camp , but the Spanish troops , with artillery support from the galleys , decimated and forced them back into Mahdia walls . Turgut Reis took refuge in his galleys and retired to Djerba . Despite the victory , the Christian losses were high . Among the dead was the commander of the Spanish artillery , Luis Pérez de Vargas . End of the siege . After the failed attack by the defenders , the Christian commanders ordered four galleys patrol the area during the night to prevent further attacks . Several others were also sent to Sicily carrying wounded and sick men and requests of replacements and ammunition , which were provided from Milan , Florence , Lucca and Genoa . Pending receipt them , the siege engineers remained looking for the weakest points of the defenses of Mahdia . 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 . Nine pieces of artillery were settled on the platform , which was protected by shields and parapet , prior to anchor the galleys off the walls . On 8 September , the guns of García Álvarez de Toledo ' s galleys , along with the land batteries and of the other naval artillery , opened fire on the city . The bombardment , which did not end until two days later , opened large gaps in Mahdia ' s defenses . Then , at the orders of their officers , the Spanish soldiers stormed the fortifications in three different points . An attack was repulsed , but the other two overwhelmed the defenders and surprised the remaining Ottoman troops from their rear . The last defenders resisted inside the towers for a while , but they were finally defeated . Governor Hesar was captured , and about 7 , 000 Mahdia ’ s soldiers and civilians were killed or captured . Aftermath . Sancho de Leyva remained in Mahdia in command of a Spanish garrison until 1553 . Charles V offered the charge of the town to the Knights of Malta but they refused it , so he ordered it to be dismantled despite to be a strategically important stronghold . The demolition tasks were carried out by Hernando de Acuña . Shortly after Mahdia was reoccupied by the Ottomans , but only to live by fishing and oil - works . The town remained under Turkish rule until the 19th century . Sultan Suleiman , meanwhile , considered that Charles had broken the Truce of Adrianople and ordered Turgut Reis to resume the war against the Christians . After summoning up Turkish reinforcements he returned to the Barbary coast in August 1551 , and succeeded in capturing Tripoli from the Knights of Malta but failed in an effort to take Malta , a failure that together with that of Oran ans Mers El Kébir allowed the capture in 1564 of Peñón de Vélez de la Gomera by Spain , a Christian success which was followed in 1565 by the decisive defense of Malta against the fleet of Turgut Reis .