In the 9th–14th centuries, the northern Iranian regions of Tabaristan, Daylam and Gilan, sandwiched between the Caspian Sea and the Alborz range, came under the rule of a number of Alid dynasties, espousing the Zaydi branch of Shi'ism. The first and most powerful Zaydi emirate was established in Tabaristan in 864 and lasted until 928. It was interrupted by Samanid occupation in 900, but restored in 914 by another Alid branch. The second period of the Alid emirate was plagued by internal dissensions and power struggles between the two branches, and ended in the second conquest of the region by the Samanids in 928. Subsequently, some of the soldiers and generals of the Alavids joined the Samanids, among them the founder of the Ziyarid dynasty, Mardavij, and Ali, Hassan and Ahmad, the sons of Buya and founders of the Buyid dynasty.
Local Zaydi rulers survived in Daylam and Gilan until the 16th century.
Hasan ibn Zayd, adopted the regnal nameal-Da'i ila'l-Haqq (864–884). He was forced to abandon Tabaristan briefly for Daylam in 869 and 874 due to invasions
Muhammad ibn Zayd, also adopted the regnal name al-Da'i ila'l-Haqq (884–900). Rule in Tabaristan proper was usurped by Abu'l-Husayn Ahmad ibn Muhammad for a few months as Muhammad was in Gurgan at the time of Hasan's death. Tabaristan was overrun briefly by Rafi ibn Harthama in 891–893, and in 900 Muhammad tried to conquer Khurasan, but was defeated and killed by the Samanids. The Samanids captured Tabaristan, and the Alavids fled to Daylam in exile (900-913).
Abu Muhammad Hasan ibn Qasim, also adopted the regnal name al-Da'i ila'l-haq (917–919, 919–923, 927–928). A Hasanid, he was the commander of the army under al-Utrush and named by the latter as his heir. His rule was challenged by al-Utrush's sons and their numerous supporters (the "Nasiris"), who seized power twice, briefly in 919 and again in 923. Regained the throne with the help of Makan ibn Kaki, ruled until he was killed in battle with Asfar ibn Shiruya.
Abu 'l-Husayn Ahmad ibn Hasan, surnamed Nasir (919, 923). Reigned jointly with his brother in 919, thereafter reconciled himself with Abu Muhammad Hasan al-Da'i until 923, when he reigned briefly until his death.
Abu Ali Muhammad ibn Abu 'l-Husayn Ahmad, surnamed Nasir (925–927). Son of Ahmad ibn Hasan, he was chosen as emir after Ja'far died. Deposed briefly by Makan ibn Kaki, who installed Isma'il ibn Ja'far as a puppet ruler, regained the throne with the aid of Asfar ibn Shiruya.
Abu Ja'far Husayn ibn Abu 'l-Husayn Ahmad, surnamed Nasir (927). Brother of Abu Ali Muhammad, he was deposed by Makan ibn Kaki, who brought back Abu Muhammad Hasan al-Da'i. Installed once more as imam briefly by Asfar ibn Shiruya under Samanid suerainty, but later removed to the Samanid court at Bukhara. Tried to recover Tabaristan in 931 with the help of Mardavij, but failed.