at the death of
Malik-Shah I in 1092 Mu'ayyid al-Mulk spent the first ten years of
Malik-Shah I's reign () in
Baghdad and
Jazira, where he was the deputy of his father and the sultan in almost the same manner as that of a viceroy. In 1078, deadly riots took place in Baghdad due to religious differences between Islamic sects. Mu'ayyid al-Mulk, who was in the city at the time, quelled the riots with the help of the
amid (Seljuk governor of Baghdad) and the
prefect. After the downfall of Abu'l-Mahasin Sayyid al-Ru'asa' in 1083/4, Mu'ayyid al-Mulk succeeded him as the ''tughra'i'' (administrative secretary). However, he was not happy with this post, and thus asked to be dismissed. He subsequently went to
Iraq, where he served as a diplomat. Mention of him in chronicles is thereafter omitted for the next 10 years. Some of
Mu'izzi's poems imply that he was in the south-eastern Iranian region of
Sistan and Khurasanian city of
Herat. Mu'ayyid al-Mulk was in Khurasan at the end of 1094, but fled to the capital
Isfahan to join
Berkyaruq, who appointed him as his vizier. He convinced or bribed the leading figures of Iraq and Khurasan who had joined
Tutush I to return to the allegiance of Berkyaruq. He also played a key-role in the defeat of Tutush in 1095, at Dashilu, near
Ray. He was reportedly personally thanked by Berkyaruq. However, he soon fell from grace. He had alienated Berkyaruq's mother Zubayda Khatun, who held great influence over her son. Furthermore, he had also bickered with his brother
Fakhr al-Mulk over jewels left by their father. The latter offered Berkyaruq a great sum of riches in return for the post of vizier, which he accepted. Mu'ayyid al-Mulk was thus dismissed. He soon entered into the service of Berkyaruq's half-brother
Muhammad I Tapar, who appointed him as his vizier. Mu'ayyid al-Mulk made use of his newfound position to exact vengeance on his rivals, which was made easier because Muhammad had yet to reach adulthood (approximately 17 years old at the time). The Nizamiyya (supporters of Nizam al-Mulk) and the prominent families of Isfahan also joined Muhammad, stopping Berkyaruq from entering the city. The rebellion was launched from Muhammad's base at the city of
Ganja in
Arran, which had been given to him as a ''
iqta''' (land grant) by Berkyaruq back in 1093. Muhammad's capture of Ray exposed the vulnerability of Berkyaruq's realm. Sa'd al-Dawla Gawhara'in, the
shihna (military administrator) of Baghdad, soon joined Muhammad, which implies that the city was also added to his domain. Nevertheless, the five-year war continued to be indecisive, with Baghdad repeatedly changing hands. Even with the support of Sanjar (who despised Berkyaruq), Muhammad was unable to defeat his rival. In 1101, Muhammad's forces were defeated in a battle near
Hamadan, which resulted in the capture of Mu'ayyid al-Mulk, who was taken to Berkyaruq, who had him personally killed. == Legacy and assessment ==