The revolt of Babak had only temporarily reduced the power of the Arab chieftains in Azarbaijan. It was evidently in part with the aim of reducing their turbulent independence and partly in order to check the ascendancy of the Bagratid kings of Armenia that the caliph al-Mu'tamid in 276/889-90 or, more likely, in 279/892 appointed one of his foremost commanders, Muhammad b. Abi'1-Saj, governor of Azarbaijan and Armenia. The Sajid family came from Ushrusana in Central Asia and was probably of Soghdian origin. Muhammad's father Abu'-Saj Devdad b. Devdasht distinguished himself in the 'Abbasid army under al-Afshin in the final war against Babak and later served the caliphs in various provinces.
After his death in 266/879 his two sons, Muhammad and Yusuf, followed his career. The first task of Muhammad in Azarbaijan was to subdue the rebel 'Abd Allah b. al-Hasan al-Hamdani, presumably a chief of the Hamdan in the province, who had occupied Maragha. In 280/893 Muhammad induced him to surrender on a promise of safety, but then confiscated his property and executed him. He took Maragha as his capital, though later he usually resided in Barda'a. Then he turned his attention to Armenia, where the Bagratid Smbat I had acceded to the throne in 890. Muhammad had sent him in the name of the caliph a crown and presents, thus affirming his overlordship. When Smbat in 892 sent envoys to the Byzantine emperor, Muhammad threatened to attack him, but was pacified by a diplomatic letter of the king. The Bagratid then occupied Dvin (Ar. Dabil), and in 895 invaded Georgia and Albania. Countering this expansion in the north Muhammad in the same year occupied Nakhchivan and Dvin, but then suffered a defeat and concluded a peace with Smbat.