and challenged Bisutun's rule. Bisutun then agreed with Rukn al-Dawla to become his vassal in return for protection against the Samanids, which forced the Samanid army to withdraw to Khorasan. In 971, the Abbasid caliph al-Muti gave Bisutun the title of Zahir al-Dawla. Bisutun later died in 977, and was succeeded by Qabus. However, he was expelled by the Buyid ruler Adud al-Dawla in 980, because he gave refuge to the latter's rival and brother Fakhr al-Dawla. The Buyids now dominated Tabaristan over 17 years while Qabus was in exile in Khorasan. In 998, Qabus returned to Tabaristan and re-established his authority there. He then established good relations with the Ghaznavid ruler Mahmud of Ghazni who had taken control of Khorasan, but still acted as an independent sovereign. During the reign of Qabus, his kingdom was a major attraction to scholars; Abu Rayhan Biruni, the great scientist of the Middle Ages, was supported by Qabus. In fact he dedicated his work Chronology to Qabus around 1000 and observed eclipses of the moon in his capital of Gorgan. Later rulers and decline 1000s–1090 Due to his tyrannical rule, Qabus was overthrown by his own army in 1012, and was succeeded by his son Manuchihr, who quickly recognized the sovereignty of Mahmud of Ghazni, and married one of his daughters. Manuchihr died in 1031, and was succeeded by his son Anushirvan Sharaf al-Ma'ali whom Mahmud of Ghazni had chosen as the heir of the Ziyarid dynasty. From 1032 to 1040, the real power behind the throne was held by Abu Kalijar ibn Vayhan, a relative of Anushirvan. In 1035, Abu Kalijar stopped paying tribute to the Ghaznavids, which led to the Ghaznavids invading Tabaristan and sacked the Ziyarid capital of Amol. Abu Kalijar, after having learned the consequences of not paying tribute to the Ghaznavids, agreed to continue paying tribute. This gave Anushirvan the opportunity to imprison Abu Kalijar and gain a firm grip over his kingdom. In 1041/1042, the Seljuqs, now the new masters of Khorasan, invaded Anushirvan's domains, which forced him to accept their authority. Anushirvan died in 1059 and was succeeded by his cousin Keikavus, the celebrated author of the Qabus nama, a major work of Persian literature. Keikavus died in 1087, and was succeeded by his son Gilanshah. His reign was however short and in 1090, the Nizari Ismaili state under Hassan-i Sabbah invaded and conquered his domains,