Al-Mu'izz, and with him the administrative apparatus of the Fatimid Caliphate, left his former capital of Mahdia, Tunisia, in 972 and arrived in Cairo in June 973. The Fatimid Empire quickly grew powerful enough to stand as a threat to the rival Sunni Abbasid Caliphate. During the reign of Caliph al-Mustansir (1036-1094), the longest of any Muslim ruler, the Fatimid Empire reached its peak but also began its decline. A few strong viziers, acting on behalf of the caliphs, managed to revive the empire's power on occasion. The Armenian vizier Badr al-Jamali (in office from 1073-1094) notably rebuilt the walls of Cairo in stone, with monumental gates, the remains of which still stand today and were expanded under later Ayyubid rule. The late 11th century was also a time of major events and developments in the region. It was at this time that the Great Seljuk (Turkish) Empire took over much of the eastern Islamic world. The arrival of the Turks, who were mainly Sunni Muslims, was a long-term factor in the so-called "Sunni Revival" which reversed the advance of the Fatimids and of Shi'a factions in the Middle East. In 1099 the First Crusade captured Jerusalem, and the new Crusader states became a sudden and serious threat to Egypt. New Muslim rulers such as Nur al-Din of the Turkish Zengid dynasty took charge of the overall offensive against the Crusaders.