Seljuq dynasty
Toghril Beg, the founder of the Seljuq dynasty, had made Esfahan the capital of his domains and his grandson Malik-Shah was the ruler of that city from 1073. An invitation was sent to Khayyam from Malik-Shah and from his vizier Nizam al-Mulk asking Khayyam to go to Esfahan to set up an Observatory there. Other leading astronomers were also brought to the Observatory in Esfahan and for 18 years Khayyam led the scientists and produced work of outstanding quality. During this time Khayyam led work on compiling astronomical tables and he also contributed to calendar reform in 1079.