 The Fatimid dynasty was succeeded by the rule of Saladin and his Ayyubid dynasty . Initially appointed vizier by the last Fatimid Caliph Al- ' <unk> ( who incorrectly thought he could be easily manipulated ) , Saladin consolidated power in Egypt , allying that country with the Sunni Abbasid Caliphate in Baghdad . Distrusting al @-@ Azhar for its Shi 'a history , the mosque lost prestige during his rule . However , the succeeding Mamluk dynasty made restorations and additions to the mosque , overseeing a rapid expansion of its educational programs . Among the restorations was a modification of the mihrab , with the installation of a polychrome marble facing . 
