 He held it until the city was captured by the Fatimid vizier of Egypt, al-Afdal Shahanshah, in 1098.After this he sought to make a name for himself in the Jezirah, where his brothers had also established themselves.He then entered the service of the Seljuq sultan Mahmud I, who granted him Hulwan and made him "shihna" of Baghdad, an office which oversaw the affairs of the caliph on behalf of the sultan.