Under al-Hafiz he rose to the powerful position of chamberlain, and emerged as the leader of the Muslim opposition during the vizierate of the Christian Bahram al-Armani in 1135–1137, when he served as governor of Ascalon and the western Nile Delta.