In 850 C.E. Al-Mutawakkil brought Yahya from one of the Abbasid provinces in order to punish him, after he had reportedly assembled a group of supporters. Umar ibn Faraj al-Rukhkhaj Al-Sijistani flogged him 18 lashes and he was incarcerated in Baghdad in the Matbaq Prison before being released.
Yahya was hard pressed by his creditors and sought a grant from Umar ibn Faraj, but was harshly denied. He thus cursed Umar ibn Faraj and as a result was imprisoned, but was later set free. He then moved to live in Baghdad, but was still suffering from hardship. He then went to Samarra where he met another man whom he asked for a grant, but was again harshly denied.
Yahya then went to Kufa, where he rebelled in 864 C.E. His uprising seems to have been a rash course of action. In Kufa, Yahya gathered a great throng of Bedouins and a contingent of Kufa also rallied around him. He then marched to Al-Fallujah and encamped at a village known as al-‘Umud. He then marched to Kufa and proceeded as far as the treasury, where he took whatever he found. Following this, he declared his rebellion in Kufa. He then liberated the two prisons of Kufa of all those interred. He then left Kufa for its agricultural hinterland and settled in a place called Bustan. He was followed and supported by a group of Zaydis, Bedouins living near Bustan and people from other certain places near Kufa. After establishing himself at Bustan his followers grew in number.
Yahya routed an Abbasid force sent to defeat him in a fierce battle near the Kufa bridge.
The Zaydis propagandized that he was the chosen one of Muhammad's family. This increased his popularity and even the mob of Baghdad held him in high esteem. In Kufa a group of experienced Shiites swore allegiance to him, along with other people. While he was in Kufa he was making preparations for his forces, while the Abbasid forces sent to defeat him were also making the necessary preparations.
On the 13thRajab 864 C.E. he marched against the Abbasid forces of Hussain ibn Isma’il, after being urged to do so by his followers.
The next day, Yahya's forces attacked Hussain ibn Isma’il forces, but were defeated and fled, abandoning Yahya on the battlefield.
Yahya was then beheaded on the battlefield in Rajab 250 A.H. and his head was mutilated. His head was then sent to Al-Musta'in, from where it was displayed at the public gate in Samarra.
Some of Yahya's companions did not accept the news that he was defeated and killed. Instead, they believed that he was not killed and he only hid himself and went into occultation and that he was the Mahdi and the Qa’im, who will reappear another time. His revolt had an interesting sequel in 255 A.H., when ʿAlī ibn Muḥammad, the leader of the Zanj Rebellion, claimed to be the incarnated form of Yahya.
Elegies written for Yahya
mentions that many elegies were written for Yahya, and that he had recorded some of them in his Kitab al-Awsat. But in his book The Meadows of Gold, it is the elegy by Ibn Abi Tahir Tayfur that he gives pride of place. Ibn Abi Tahir's elegy on the crucified Zaydi rebel is composed of 14 lines and the poem was possibly recited in Samarra, where Yahya's head was displayed, or else before the large crowds that are known to have gathered in Baghdad. In the elegy, Ibn Abi Tahir attacks the Sunni Abbasid Caliphal family for its usurpation of the rights of the house of Ali. Ibn al-Rumi also published elegies on Yahya.