Zengid dynasty
Shirkuh's nephew Saladin was appointed vizier by the Fatimid caliph al-Adid and Governor of Egypt, in 1169. Al-Adid died in 1171, and Saladin took advantage of this power vacuum, effectively taking control of the country. Upon seizing power, he switched Egypt's allegiance to the Baghdad-based Abbasid Caliphate which adhered to Sunni Islam, rather than traditional Fatimid Shia practice. Three years later, he was proclaimed sultan following the death of his former master, Nur al-Din of the Zengid dynasty and established himself as the first Custodian of the Two Holy Mosques.