The Mahdia campaign of 1087 was a raid on the North African town of Mahdia by armed ships from the northern Italian maritime republics of Genoa and Pisa. Mahdia had been the capital of Ifriqiya under the Fatimids, chosen due to its proximity to the sea which allowed them to conduct naval raids and expeditions such as the raid on Genoa in 935. After the Fatimid conquest of Egypt, the region was under the control of the Zirids who remained part of the Fatimid Caliphate until 1048 when the Zirids renounced Shia Islam. In response, the Fatimids send the Arab tribes to Ifriqiya to subdue the revolt. As a result of the ongoing fighting and anarchy, the previously flourishing agriculture decreased and the coastal towns became more important as both centers for maritime trade as well as bases for piracy against Christian shipping. The raid had been prompted by the actions of the Zirid ruler Tamim ibn Muizz (reigned 1062–1108) as a pirate in waters off the Italian Peninsula, along with his involvement in Sicily fighting the Norman invasion. In this context, Tamin had ravaged the Calabrian coast in 1074, taking many slaves in the process, and capturing temporarily Mazara in Sicily in 1075 before negotiating a truce with Roger that ended Tamin's support for the emirs of Sicily. These campaigns and raids by other Arab pirates threatened the growing economics interests of the Italian maritime republics and thus provided motivation for attacking the Zirid stronghold. This had led the Pisans to engage in military action before Mahdia, such as in briefly seizing of Bone in 1034 and military aiding the Norman conquest of Sicily in 1063. The attack was led by Hugh of Pisa, with military aid from Rome and the Genoese navy; the nobleman Pantaleone from Amalfi was also possibly involved, and the whole endeavour had the backing of Matilda of Tuscany. Most likely no cavalry was used as neither Latin nor Arab sources mention horses or cavalry, pointing out that capabilities to transport horses on long distance journeys was at this time beyond the capabilities of the Italian republics. The united forces succeeded in capturing the city, burning Mahdia's fleet as well as extracting from Tamin an indenmity which was shared between Pisa and Genoa. As they could not hold the city, it was possibly offered to Roger of Sicily, who refused due to the treaty he