The Fatimids. The Fatimid Caliphate (909-1171) was the great Shia rival to the Sunni caliphs of Baghdad - an empire that began with a revolutionary movement in North Africa and ended up ruling from one of the greatest cities of the medieval world, Cairo, which the Fatimids themselves founded. The dynasty claimed descent from Fatima, the Prophet Muhammad's daughter, and her husband Ali: to their Ismaili Shia followers, the Fatimid caliph was not merely a ruler but the Imam, the divinely guided leader of all Muslims.
The movement began in the early 900s, when the Ismaili missionary Abu Abdallah won over the Kutama Berbers of what is now Algeria and overthrew the Aghlabid rulers of Ifriqiya (Tunisia) in 909. From concealment in far-off Sijilmasa came Abdallah al-Mahdi, accepted as the long-awaited Imam and first caliph. For sixty years the Fatimids ruled from Tunisia, fighting off Abbasid agents, Umayyad Spain, and their own Berber rebels, while their missionaries - the da'is - quietly built networks of supporters across the Islamic east.
In 969 the general Jawhar conquered Egypt almost without a fight, and the Fatimids built their new capital beside the Nile: al-Qahira, 'the Victorious' - Cairo. Under al-Mu'izz, al-Aziz, and the long, strange reign of al-Hakim, Egypt became the richest state in the Mediterranean, its fleets dominating the sea lanes and its merchants linking the Indian Ocean trade to Europe. They founded al-Azhar mosque and its academy, still today a great center of Islamic learning, and presided over a cosmopolitan court of Sunni officials, Christian administrators, and Jewish merchants - the caliphate never managed to convert its own mostly-Sunni population to Ismailism, and mostly did not try.
The long reign of al-Mustansir (1036-1094) brought decay: army factions fought in the streets of Cairo, famine struck, and the empire lost Syria to the Seljuk Turks and then Jerusalem to the Crusaders in 1099. Viziers like Badr al-Jamali and his son propped up the shrinking state for another century, but in 1171 the last caliph's own vizier - the young Saladin - quietly abolished the dynasty, returned Egypt to the Sunni fold and the Abbasid name, and founded his own Ayyubid sultanate on the Fatimid inheritance.