A historic overview
After the conquest of the Buwayhids of Iraq and the takeover of Baghdad by the Seljuqs under Toghrul Bey in 1055, there was general anarchy in the city, and a staunch orthodox agenda was pursued. The conquest was followed by large-scale rioting, and the main targets were the Buwayhid state's institutions and centres of Shi'a learning, which were systematically sacked and burnt down by Seljuq troops, who were joined in by the local Sunni population. This included the 80000 volume-strong library built up by the Twelver scholar Murtada al- Radi. During these events prominent Shi'a scholars retired to less dangerous areas, especially Najaf. After consolidating their conquest, one of the first tasks the Seljuqs undertook was to set up institutions of higher learning, to undo the scholarly damage done to the Sunni tradition in Buwayhid times. The famed Seljuq minister Nizam al-Mulk was set around this task, and the institutions which emerged as a result were promptly named Nizamiyyas after him.
The foundations of the religious struggles of the next two centuries, between a Sufi-cloak donning Nizari Isma'ilism, and a resurgent Sunnism under Turkic rule, were laid in the late 1000s, and are personified by the ideological struggles of three vibrant personalities. While Hasan bin Sabbah reinvigorated Isma'ilism at Alamut, his childhood acquaintances 'Umar Khayyam and (in anecdote) Nizam al-Mulk – who was also an ideological nemesis, played a vital part in the creation of Seljuq state institutions in conquered areas. It is their groundwork that gave the foreign Seljuqs religious and cultural legitimacy in Iran and Iraq in the aftermath of the Shi'a-dominated tenth century.
The most famous Nizamiyya was the one set up by Nizam al-Mulk in Baghdad in 1065, under Toghrul's successor and Malik Shah's predecessor Alp Arslan (ruled 1063-1072). However, it is unlikely that in the immediate aftermath of the Buwayhids, whose rule saw the consolidation of the Twelver community, scholarship like the Ikhwan al-Safa, and the free movement of Isma'ili missionaries, that Shi'ism in Iraq would just disappear on the arrival of the Seljuqs. In all likelihood much of it probably went underground for survival, using the traditional Shi'a practice of taqiyya or dissimulation, and subsequently started expressing itself in newer and more discreet ways.