After this, Anushirvan went to Baghdad, where he later became head of the Seljuq military once again. He was shortly appointed by Mahmud II as his vizier in 1127, and remained in that office until 1128. Anushirvan served as the vizier of the Abbasid caliph al-Mustarshid from 1132 to 1134, and then briefly as the vizier of the new Seljuq Sultan Ghiyath ad-Din Mas'ud from 1135 to 1136.