Arab chieftains of Adharbayjan and partly to curb the dominance of the Bagratid kings of Armenia, the caliph al-Mu'tamid installed Muhammad ibn Abi'l-Saj as the governor of Adharbayjan and Armenia in 889/90, or more likely, in 892. The latter belonged to the Sajid family, native to Ushrusana and most likely of Sogdian origin. Muhammad's first challenge came in the form of 'Abd-Allah ibn al-Hasan ibn al-Hamdani, a rebel who had taken control of Maragheh. Muhammad convinced him to surrender in 893 by promising his safety, but once 'Abd-Allah did so he was executed by the Sajid. Maragheh was afterwards made Muhammad's capital, though he usually resided in Barda'a. Muhammad amassed so much authority that he briefly declared independence from the caliphate. Following Muhammad's death to an epidemic in 901, his troops installed his son Devdad ibn Muhammad on the throne. Five months after, however, the latter was removed from power by his uncle Yusuf ibn Abi'l-Saj, who destroyed the walls of Maragheh and moved his capital to Ardabil. In 909, Yusuf was officially acknowledged as the ruler of Adharbayjan and Armenia by the newly ascended caliph al-Muqtadir. A dirham struck by Yusuf at Maragheh from the same year has been found. The last Sajid ruler, Abu'l-Musafir al-Fath, was killed at Maragheh in 929. Daylamite rule Following the collapse of the Sajid kingdom, the Kurdish commander Daysam ibn Ibrahim al-Kurdi attempted to establish his rule over Azerbaijan, but he was eventually defeated in 941/42 by Marzuban ibn Muhammad (), who gained control over the region, expanding his realm as far as Dvin in Armenia. The latter belonged to the Sallarid dynasty, of Daylamite stock and originally centered in the Tarum district of Daylam. In 948, Azerbaijan was briefly controlled by the Buyid dynasty, as demonstrated by a coin struck at Maragheh by Abu Mansur Muhammad, a general of the Buyid ruler Rukn al-Dawla (). Rawadid and Seljuk rule Following the death of the Sallarid Ibrahim I ibn Marzuban I in 983, Azerbaijan (excluding a small part, possibly Miyana) was conquered by the Kurdish Rawadids, former vassals of the Sallarids. In 1039, Maragheh was sacked by a wave of immigrating Oghuz Turks, who destroyed its mosque and killed many of its inhabitants. In 1054, the Rawadid ruler Abu Mansur Wahsudan () was forced to submit to the Seljuk ruler Tughril (). In 1070, Tughril arrested Wahsudan's son and successor Abu Nasr Mamlan