Hamdawayh was the son of Ali ibn Isa ibn Mahan, a former leader of the abna' and the long-serving governor of Khurasan during the caliphate of Harun al-Rashid. He himself first appears in 815, when he was an officer serving among forces loyal to al-Hasan ibn Sahl in southern Iraq, during the tumultuous period in the aftermath of the civil war between the rival caliphsal-Amin and al-Ma'mun. Following the death of the pro-Alid rebel Abu al-Saraya al-Sirri in late 815, Hamdawayh was appointed by al-Hasan as governor of the Yemen, which was then in the hands of the AlidIbrahim ibn Musa al-Jazzar, and tasked with recovering the province for al-Ma'mun. After arriving in Mecca alongside the caliph's brother Abu Ishaq, who had been put in charge of the pilgrimage of 816, Hamdawayh advanced upon the Yemen and met Ibrahim's forces in battle. Ibrahim was defeated and forced to flee, allowing Hamdawayh to take control of Sana'a and the Yemeni highlands. Following al-Ma'mun's designation of Ibrahim ibn Musa's brother Ali ibn Musa al-Rida as his successor in 817, the central government reconciled with Ibrahim and formally invested him with the governorship of the Yemen. This act was opposed, however, by Hamdawayh and many of the Yemenis, who refused to recognize the appointment. When Ibrahim marched toward Sana'a in 818, Hamdawayh went out to meet him with his army, and in a sharp engagement defeated the Alid and killed a large number of his men. Ibrahim was compelled to retreat to Mecca, and Hamdawayh retained command of the province, though now as a rebel. Hamdawayh's rule in the Yemen lasted until 820, when al-Ma'mun appointed Isa ibn Yazid al-Juludi as governor of the province. Isa advanced south and routed Hamdawayh's forces in battle, forcing Hamdawayh to withdraw and seek refuge in Sana'a. Isa, however, pursued him and entered the town, and eventually found where the rebel was staying. Hamdawayh was then captured and placed under arrest, and shortly afterwards he was dispatched to al-Ma'mun in Baghdad.
Establishment of the Ziyadids
During Hamdawayh's governorship, the caliphal general Muhammad ibn Abdallah ibn Ziyad established his rule over the Tihamah region of western Yemen. This area subsequently remained under the control of the Ziyadid dynasty, and the authority of succeeding governors of Yemen proper was restricted to Sana'a and the highlands of the country.