After a brief visit to Tabaristan to see his mother, he returned to Gurgan as an assistant to Hasan's brother-in-law, Muhammad ibn Ibrahim.
[3] In 880, Muhammad also suppressed the rebellion of Rustam I, a member of the native Bavandid dynasty which ruled the mountains of eastern Tabaristan and opposed the Zaydids.
Muhammad was prevented from returning to Tabaristan straight away by a mutiny by his Daylamite troops, and was able to regain control of Gurgan itself only through the aid of the former Tahirid general and now ruler of Khurasan, Rafi' ibn Harthama.
[1] Muhammad now attacked Rustam, who had supported the usurper Ahmad, and drove him from his domains to seek refuge at the Saffarid court.
Rafi' launched a major invasion of the Zaydid domains and conquered most of them, forcing Muhammad, like his brother before him, to seek shelter in the mountain fortresses of the western districts.
[1][3][4] In 897, Muhammad provided refuge to Bakr ibn Abd al-Aziz, a scion of the deposed Dulafid dynasty of Isfahan.
[3] In 900, the balance of power in the region changed abruptly with the defeat and death of the Saffarid Amr ibn al-Layth by the Samanids in April of that year.
This religious oppression, combined with their reliance on the Daylamite mountaineers, whose lack of discipline and barbarous behaviour were much resented by the populace, resulted in an estrangement of the mass of the people from Zaydid rule.
[3][4] Muhammad achieved some prominence among the Shi'ites by sponsoring the rebuilding of the shrine to Ali and his son Husayn after its destruction by the Abbasids, as well as by his liberal donations to other members of the Alid family across the Muslim world.
[1] Muhammad was also a cultured man, who appreciated good poetry and even composed poems of his own, of which only a few lines survive, recorded by al-Suli.