Al-Mahdi Muhammad bin Ahmed (October 27, 1637 – August 2, 1718), also known as Ṣāḥib al-Mawāhib, was an Imam of Yemen who ruled in 1689–1718. He belonged to the Qasimid family that was descended from the Islamic prophet Muhammad and dominated the Zaidi imamate in 1597–1962.
Muhammad was the son of the imam al-Mahdi Ahmad. When the latter died in 1681, Muhammad was prevented from succeeding him. When the next imam al-Mu'ayyad Muhammad II died in 1686, a struggle for the imamate broke out between various contenders for a period of three years. Muhammad claimed the imamate in Mansura, but was besieged by opposing relatives. However, he managed to break the siege and capture the enemy leaders. He was now generally acknowledged by the various parts of the country. He is known under the name Ṣāḥib al-Mawāhib because he kept his residence in al-Mawahib east of Dhamar.
Al-Mahdi Muhammad was known to Zaidi historiography as a tough and arbitrary ruler who was unwilling to listen to advice. He exacted taxes that were not according to the shariah. On the other hand, he had an ascetic outward appearance and declined silk or fine cloths. His arbitrary killings of subjects gave rise to popular beliefs that his evil actions were influenced by a jinn. A French delegation met the imam in February 1712. The visitors described him as a man about 80 with handsome figure and countenance. He displayed very little pomp except when going to the Friday prayer; then he would be accompanied by 1,000 foot soldiers and 200 horsemen, together with mounted officers of the household and court.
After the Jewish exiles had returned from their banishment to Mawza, Imam al-Mahdi Muhammad is said to have drawn the Jews near to himself, defended them and made it possible for them to return to their previous status.
Al-Mahdi Muhammad's long reign was interspersed with internal rebellions and crises. In 1689 he attempted to win back Yafa in the east, which had been lost to the Zaidi state in the previous reign. The enterprise failed, however, and Yafa tribesmen raided Ibb in 1708. Sa'dah in the far north rebelled in 1691 under the emir Ali bin Ahmad bin al-Qasim. The emir led an army of tribesmen against San'a, but the siege was defeated. The imam's troops, in turn, conquered Sa'dah and forced Ali to flee. In 1699 a Sayyid, Ibrahim al-Mahatwari, rose against the imam. He was reputed to be a great magician, and his ecstatic followers defeated several of the imam's armies. Eventually he claimed to be the expected Mahdi of Shi'a belief. The imam's sons finally crushed the rebellion, and Ibrahim al-Mahatwari was killed. On the positive side, the reign of al-Mahdi Muhammad enjoyed some external prestige. In 1701-1702 he received envoys from Shah Abbas II of Persia and the Ottoman pasha in Jeddah. The soaring prices of coffee, which was still almost solely produced in Yemen, underpinned the resources and prestige of the imamate.