marks a pivotal moment in the decline of that city, which was later eclipsed by Cairo itself. Eventually, Salah ad-Din (Saladin), a Zengid commander who was given the position of al-'Adid's vizier in Cairo, declared the end and dismantlement of the Fatimid Caliphate in 1171. Cairo thus returned to Sunni rule, and a new chapter in the history of Egypt, and of Cairo's urban history, opened. Cairo's ascendance in the Ayyubid and Mamluk periods Salah ad-Din's reign marked the beginning of the Ayyubid dynasty, which ruled over Egypt and Syria and carried forward the fight against the Crusaders. He also embarked on the construction of an ambitious new fortified Citadel (the current Citadel of Cairo) further south, outside the walled city, which would house Egypt's rulers and state administration for many centuries thereafter. This ended Cairo's status as an exclusive palace-city and started a process by which the city became an economic center inhabited by common Egyptians and open to foreign travelers. Over the subsequent centuries, Cairo developed into a full-scale urban center. The decline of Fustat over the same period paved the way for its ascendance. The Ayyubid sultans and their Mamluk successors, who were Sunni Muslims eager to erase the influence of the Shi'a Fatimids, progressively demolished and replaced the great Fatimid palaces with their own buildings. The Al-Azhar Mosque was converted to a Sunni institution, and today it is the foremost center for the study of the Qur'an and Islamic law in the Sunni Islamic world. In 1250 the Ayyubid dynasty faltered and power transitioned to a regime controlled by the Mamluks. The mamluks were soldiers who were purchased as young slaves (often from various regions of Central Eurasia) and raised to serve in the army of the sultan. They became a mainstay of the Ayyubid military under Sultan al-Salih and eventually became powerful enough to assume control of the state for themselves in a political crisis during the Seventh Crusade. Between 1250 and 1517, the throne passed from one mamluk to another in a system of succession that was generally non-hereditary, but also frequently violent and chaotic. Nonetheless, the Mamluk Empire continued many aspects of the Ayyubid Empire before it, and was responsible for repelling the advance of the Mongols in 1260 (most famously at the Battle of Ain Jalut) and for putting a final end to the Crusader states in the Levant. Under the reign