In the 10th century Mahdia was a very important city, but even more, it was the capital of one of the Muslim worlds most important line of rulers, the Fatimids. The first Fatimid ruler declared himself as the Mahdi, the last prophet of Islam. The Fatimids moved their centre to Egypt after conquering Cairo, and Mahdia had been the capital for just 50 years.
Proclaimed the capital of Tunisia in 921, Mahdia was long the center of a power struggle between the Caliph of Cairo and local sovereigns. Repeatedly attacked by nomads, Genoese navies, Sicilian troops, liberated by the Berbers, Mahdia became a headquarters for the pirates of Dargouth and battles with Spanish and Maltese knights.
The Central Mosque, austere and sober dates from the 10th century and the entrance to the Medina is through an enormous 16th century gate. Wandering through the old city visitors can see the vestiges of the ancient ramparts and fortress, visit the "Cape Africa" lighthouse and hauntingly beautiful sailors cemetery.