information:filtering, structural:scholar_edition, structural:reformatting
Buyid and Seljuq control (945–1118)

Despite the power of the Buyid amirs, the Abbasids retained a highly ritualized court in Baghdad, as described by the Buyid bureaucrat Hilal al-Sabi', and they retained a certain influence over Baghdad as well as religious life. As Buyid power waned with the rule of Baha' al-Daula, the caliphate was able to regain some measure of strength. The caliph al-Qadir, for example, led the ideological struggle against the Shia with writings such as the Baghdad Manifesto. The caliphs kept order in Baghdad itself, attempting to prevent the outbreak of fitnas in the capital, often contending with the ayyarun.

With the Buyid dynasty on the wane, a vacuum was created that was eventually filled by the dynasty of Oghuz Turks known as the Seljuqs. By 1055, the Seljuqs had wrested control from the Buyids and Abbasids, and took temporal power. When the amir and former slave Basasiri took up the Shia Fatimid banner in Baghdad in 1056–57, the caliph al-Qa'im was unable to defeat him without outside help. Toghril Beg, the Seljuq sultan, restored Baghdad to Sunni rule and took Iraq for his dynasty.

Once again, the Abbasids were forced to deal with a military power that they could not match, though the Abbasid caliph remained the titular head of the Islamic community. The succeeding sultans Alp Arslan and Malikshah, as well as their vizier Nizam al-Mulk, took up residence in Persia, but held power over the Abbasids in Baghdad. When the dynasty began to weaken in the 12th century, the Abbasids gained greater independence once again.