son al-Muktafi as governor in Rayy, Qazvin, Qum and Hamadan. The Dulafids were confined to their core region around Karaj and Isfahan, before being deposed outright in 896. Nevertheless, the Abbasid hold over these territories remained precarious, especially due to the proximity of the Zaydi emirate in Tabaristan, and in 897 Rayy was handed over to Saffarid control. The Abbasid–Saffarid partnership in Iran was most clearly expressed in their joint effort against the general Rafi ibn Harthama, who had made his base in Rayy and posed a threat to both caliphal and Saffarid interests in the region. Al-Mu'tadid sent Ahmad ibn Abd al-Aziz to seize Rayy from Rafi, who fled and made common cause with the Zaydis of Tabaristan in an effort to seize Khurasan from the Saffarids. However, with Amr mobilizing the anti-Alid sentiments of the populace against him and the expected assistance from the Zaydis failing to materialize, Rafi was defeated and killed in Khwarazm in 896. Amr, now at the pinnacle of his power, sent the defeated rebel's head to Baghdad, and in 897 the Caliph transferred control of Rayy to him. The partnership finally collapsed after Mu'tadid appointed Amr as governor of Transoxiana in 898, which was ruled by his rivals, the Samanids. Al-Mu'tamid deliberately encouraged Amr to confront the Samanids, only for Amr to be crushingly defeated and taken prisoner by them in 900. The Samanid ruler, Isma'il ibn Ahmad, sent him in chains to Baghdad, where he was executed in 902, after al-Mu'tadid's death. Al-Mu'tadid in turn conferred Amr's titles and governorships on Isma'il ibn Ahmad. The Caliph also moved to regain Fars and Kirman, but the Saffarid remnant under Amr's grandson Tahir proved sufficiently resilient to thwart the Abbasid attempts to capture these provinces for several years. It was not until 910 that the Abbasids managed to regain the coveted Fars province. Rise of sectarianism and fragmentation in the periphery In the course of the 9th century, a range of new movements emerged, based on Shi'ite doctrines, which replaced Kharijism as the main focus for opposition to the established regimes. They gained their first successes in the periphery of the Abbasid empire: the Zaydi takeover in Tabaristan was repeated in 897 in Yemen. Under al-Mu'tadid, a new danger appeared closer to the Caliphate's metropolitan areas: the Qarmatians. A radical Isma'ili sect founded in Kufa around 874, the Qarmatians were originally a sporadic and