Syria and Armenia. He then cast an eye upon Baghdad. It was at a moment when the city was in the last agony of violence and fanaticism. Toghrül, under cover of intended pilgrimage to Mecca, entered Iraq with a heavy force, and assuring the Caliph of pacific views and subservience to his authority, begged permission to visit the capital. The Turks and Buwayhids were unfavorable, but Toghrül was acknowledged as Sultan by the Caliph in the public prayers. A few days after, Toghrül himself — having sworn to be true not only to the Caliph, but also to the Buwayhid amir, al-Malik al-Rahim, made his entry into the capital, where he was well received both by chiefs and people. The Turkic general Arslan al-Basasiri revolted in 1058 and successfully took Baghdad while Tughril was occupied with his brother's revolt in Iran. Al-Qa'im originally stayed in Baghdad during these events but was later exiled to Anah on al-Basasiri's orders. For about a year, al-Basasiri kept al-Qa'im as his hostage in Anah, as a bargaining chip in negotiations with Tughril. Tughril ended up securing al-Qa'im's freedom by going directly to the amir guarding him, bypassing negotiations with al-Basasiri altogether. After al-Basasiri died and his revolt came to an end, the Seljuks were left as the single dominant power over al-Qa'im's caliphate. They were similar to the Buyids in this regard, although the Sunni Seljuks were more closely aligned with al-Qa'im in religious matters. Sectarian conflict was a prominent issue during this part of al-Qa'im's reign. A notable incident concerned the opening of the Nizamiyya of Baghdad, a madrasa affiliated with the Shafi'i legal school, in 1067; its opening inflamed tensions with the Hanbalis. Al-Qa'im was reluctant to act without first consulting with the Seljuk sultan and was ultimately unable to control the situation. Fakhr ad-Dawla Muhammad ibn Muhammad ibn Jahir was appointed as vizier by al-Qa'im in 1062. Fakhr ad-Dawla arrived and was "showered with gifts, robes of honor, and the title Fakhr ad-Dawla ('glory of the dynasty')." According to Sibt ibn al-Jawzi, he was also given the additional title Sharaf al-wuzarā'''. Fakhr ad-Dawla's first tenure lasted until 1068, when he was dismissed for a series of "infractions" (dhunūb) he had committed. The reasons included "his presence in the Bāb al-Hujra (Privy Chamber) without permission, and his wearing of 'Adud ad-Dawla's ceremonial robes." In other words, he had been acting above his