Mahdia campaign of 1087

The Mahdia campaign of 1087 was an attack on the North African town of Mahdia by armed ships from the northern Italian maritime republics of Genoa and Pisa. It 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. The attack was led by Hugh of Pisa, with military aid from Rome and the Genoese navy; the nobleman Pantaleone from Amalfi was also involved, and the whole endeavour had the backing of Matilda of Tuscany. It succeeded in capturing the city, but they could not hold it; the money from the plunder was spent on the cathedral at Pisa and to build a new church.

Crusade historian Carl Erdmann considers the raid a direct precursor to the First Crusade ("ganz als Kreuzzug ausgeführt") which occurred eight years later, as it was conducted under the banner of St. Peter against a Muslim ruler who was demonised in the accounts of it, and a form of indulgence was granted to the campaigners by Pope Victor III.

The main source of information for the campaigns is the Carmen in victoriam Pisanorum, written within months of it by a Pisan religious cleric.