The medieval tale of theThree Schoolfellows (Persian:سه یار دبستانی) narrates how the vizierNizam al-Mulk, the Nizari revolutionaryHasan-i Sabbah, and the mathematician-poetOmar Khayyam made a success-sharing pact when they were classmates in their youth, eventually leading to the assassination of the vizier by Hasan's followers, while the third was no longer interested in power.
The tale which is recorded in multipleclassical Persian sources is considered as fable by most modern scholars, but some have argued that it is inspired by real events.
The tale was first attested in the 14th-centuryJami' al-tawarikh ofRashid al-Din Hamadani, and later by other Persian authors. It was brought to Western literature byEdward FitzGerald's introduction to his English translation ofRubaiyat of Omar Khayyam. FitzGerald had usedMirkhvand as a source, who in turn had derived a different version of the story from a dubious source, theWasaya’ of Nizam al-Mulk,[1]

Hasan-i Sabbah,Nizam al-Mulk, andOmar Khayyam were classmates in their youth under the same master, Imam al-Muwaffaq, in the city ofNishapur. Knowing that the students of the Imam often end up reaching high success, they made a pact, proposed by Hasan, that whichever of them rose to prominence first would help the other two.[2]
Rising from a low position, Nizam al-Mulk eventually became the vizier of theSeljuk Empire, and, after being approached by Omar Khayyam, offered the other two provincial governorship, both of whom refused for different reasons: Omar Khayyam, now a scholar, was not interested in a public position and instead accepted a regular stipend and continued his literary and scientific career, while Hasan-i Sabbah ambitiously wanted a higher position in the court itself, which was granted.[2]

Hassan was later accused by some for plotting against Nizam al-Mulk to replace him as the vizier, and the latter plotted against Hasan in response, forcing him to flee toRayy and then to the IsmailiEgypt. Nizam ceaselessly hunted Hasan as the latter secretly returned to Persia as the founder of the newNizari Ismaili movement and besieged his new headquarters ofAlamut during theNizaris' revolt, eventually becoming the victim of the first and most famousassassination by the followers of Hasan (who later became known as the "Assassins").[2]
Most modern scholars consider the story as a fable,[3] due to age discrepancies of the three protagonists as well as their different places of residence during their youth.[1] Nevertheless, Ismaili scholar Ali Mohammad Rajput argues that the story is likely true, noting the school attendance of people at different ages, and the existence of three independent accounts of (parts of) the story. Jawad al-Muscati considers the story a fabrication by Hassan Sabbah's enemies.[2]
According to Harold Bowen, the story may originate from the actual relationship between Nizam al-Mulk and two of his contemporaries: the poetSayf al-Din Bakharzi and the Seljuk bureaucratAbu Nasr Kunduri. All of them were close in age and had contact to the Nishapuri teacher Imam al-Muwaffaq. Kunduri was dismissed from his position and was executed, partly due to Nizam al-Mulk's actions, while the latter patronized Bakharzi's poetry.[2][4]