The story of the three school-fellows is unlikely to have much truth as Nizam ul-Mulk was probably born some thirty years prior to Omar Khayyam.
Nizam-Al-Mulk drew up a set of protocols for the governance of the empire called the Siyasat Nameh, the two most influential institutions of which were the offices of atabeg, and the right of iqta.
Atabegs were military advisers to young princes who frequently ended up usurping the power entrusted to them, while iqta was a grant of the income from land to an official who was entrusted with its running. In theory no ownership in the land passed but in practice large hereditary estates developed. Both these institutions led to a massive decentralisation of power and this in turn facilitated and prolonged the factional fighting which characterised the Seljuk period of power.
After administering the affairs of Malek Shah for some thirty years Nizam-Al-Mulk was overthrown at the instigation of Toorkan Khatun, the principal sultana, aided by his enemy Taj Al Mulk, the Chamberlain. He was impeached after he had rashly declared that his cap and ink-horn, the badges of his office, were connected by divine decree with the throne and diadem of the Sultan. At the age of ninety-three, Nizam-Al-Mulk was thus dismissed from office and murdered by a follower of Hassan Sabah, who was by that time a personal enemy of Nizam-Al-Mulk.
A Kufic inscription at the base of the brick dome, shown above, built between 1072 and 1092, in the Southern part of the Masjed-e-Jomeh in Isfahan bears the names of Malek Shah and Nizam-Al-Mulk and is silent witness to their contribution to the architectural heritage of Isfahan. There is a story, quoted in Pope (p. 956), concerning the rivalry that existed between the two different intellectual groupings of religious jurists of the time, the Shafi'ites and the Hanafites. Nizam was open in his support for the former while Malek Shah tended to support the latter. Nizam handed over the mosque to the Shafi'ites to teach their theories there, and a riot ensued during which the Shafi'is seem to have destroyed part of the southern part of the mosque, which led to the reconstruction of the dome by Nizam.
Gibbon thought highly of Nizam Al Mulk, and called him "one of the most illustrious ministers of the East.", however as a person he seems to have been aloof and autocratic and the subject of much satire. Moreover it is not certain that he was as fully trusted by Malek Shah as Gibbon thought. There is a story that one of Nizam's relatives and protégés, the Governor of Balkh, after hearing that Malek Shah's jester Ja'farak, had been active in inventing and circulating satirical and slanderous stories about the vizier, came in a rage to Isfahan in 1082, and tore out the jester's tongue, killing him in the process. Malek Shah did nothing openly to avenge the death of his jester but had the governor poisoned, while hypocritically commiserating with the vizier.
Some of this lofty disdain can be seen inside the high, austere and secretive dome which he built, especially when compared to the dome on the other side of the mosque, built by his rival, Taj al-Mulk which is smaller, elegant, and of which nearly every part can be seen to conform to the rules of golden Section.
Nizam Al-Mulk is buried in Isfahan in a Theological School, to the North of Ahmad Abad, which he built. The Mausoleum contains a number of other graves which are said to include those of Malek Shah and Toorkhan Khatoon.