Muhammad bin Yahya was a grandson of Imamal-Mansur Ali I. In 1845 he claimed the imamate from the weak incumbent al-Mansur Ali II. In this he was supported by Sharif Husayn of Abu Arish, who acted as autonomous lord in the Yemeni lowlands under formal Ottoman suzerainty. With a strong force Muhammad bin Yahya appeared outside the capital San'a. The inhabitants endorsed his claim, opened the gates of the city and deposed al-Mansur Ali II. The usurper took the name al-Mutawakkil Muhammad. The period of Al-Mutawakkil Muhammad's reign was marked by the severe oppression of his Jewish subjects in Sana'a, forcing many of them to flee the city and to take-up refuge elsewhere. Many of them, under the orders of the Imam's viceroy, Abū-Zayid b. Ḥasan al-Miṣri, were incarcerated, and shackled in fetters of iron, while others severely beaten and tormented, until they could appease their antagonists by paying large sums of ransom money. The friendship between the new imam and Sharif Husayn was short-lived. Al-Mutawakkil Muhammad was probably encouraged by the Sharif of Mecca, Muhammad bin Awn, to attack Abu Arish. The imam aimed to win back Zaidi power in the Yemeni lowland. In 1847-1848, the imam's forces defeated Sharif Husayn and took him prisoner. Important cities like Zabid, Bayt al-Faqih and Mocha were captured by al-Mutawakkil Muhammad's forces. Sharif Husayn was kept in the mountain fort al-Qutay. However, the valuable prisoner was freed and took up arms against the imam again. Yam tribesmen from Najran and Haraz chose to support Sharif Husayn and defeated the Zaidi forces. Mocha was recaptured by the Sharif through the treachery of the garrison. Al-Mutawakkil Muhammad's position was now precarious, but he resumed the offensive in late 1848 and early 1849, capturing Ta'izz and Yarim.
Ottoman intervention
By now, however, the Ottoman government resolved to settle the unruly conditions in Yemen by imposing direct control. In April 1849 the Turkish commander Tevfik Pasha arrived with a strong detachment in Hudaydah on the coast and forced Sharif Husayn to surrender. The Sharif later died on his way to Constantinople where he had been going plead his cause. As for al-Mutawakkil Muhammad, he was summoned to appear in Hudaydah and hesitantly came to meet the pasha. Despite the imam's concerns, a convention was signed to the effect that the imam would continue to govern the country under his direct control, but only as a vassal of the Porte. Parts of imam's revenues were to go to the Ottoman treasury, and a garrison was to be placed in San'a. Al-Mutawakkil Muhammad arrived in San'a with Tevfik Pasha and the Turkish troops on 15 July 1849. On the next day, however, a general uprising broke out in the city and a hundred Turks were killed. Tevfik Pasha, who had been critically wounded, immediately deposed al-Mutawakkil Muhammad and raised al-Mutawakkil Muhammad's kinsman and predecessor al-Mansur Ali II to the imamate again. After 25 days the Turkish troops decided to retreat to Hudaydah, leaving the Zaidi state to its own devices for the next 23 years. Al-Mansur Ali imprisoned the deposed imam on the grounds of treachery, and beheaded him on 11 December 1849. According to one writer, "he was one of the most accomplished of men, but fate was not on his side".