# Midrarid dynasty

The Midrarid dynasty (Arabic: بنو مدرار, romanized: Banu Midrār) was a Berber dynasty that ruled the Sijilmasa region in Morocco from their capital of Sijilmasa, starting in the late 8th or early 9th century to 976/7.

## History

The exact origin or date of foundation of the Midrarid dynasty are unclear, as the main sources—in the main, al-Bakri, Ibn Khaldun, Ibn Idhari, and Qadi al-Nu'man—are not in agreement over the details, and two different traditions are reported. According to the first, the family was founded by a Sufri Miknasa Berber, Samgu ibn Wasul. Samgu led the establishment of the town of Sijilmasa in 757/8, and in 772, became its second ruler. According to the second version, the dynasty was established by a smith called Midrar, who fled the suppression of the Ribad revolt in Córdoba against al-Hakam I in 818, and settled at the site where Sijilmasa was later established. According to Charles Pellat, it is clear that Sijilmasa was already in existence by the late 8th century, but on the other hand, the arrival of Midrar in c. 823/4 tallies with the frequently repeated statement by the medieval sources that the dynasty lasted for 160 years, and the fact that a person of that name, which the dynasty is named after, is not mentioned before then. It therefore appears that the Midrarid dynasty either appeared in 823/4, or likely was a separate line descended from Samgu, but any such connection is tentative.
According to al-Bakri's Book of Routes and Places, Sufrite Kharijites first settled the town in the wake of the Berber revolts against the Umayyads. Al-Bakri recounts that others joined these early settlers there, until they numbered around four thousand, at which point they laid the groundwork for the city. They elected a leader, 'Isa bin Mazid al-Aswad (the Black), to handle their affairs during the earliest first few years after the town's establishment. However, after ruling for 14 years, he was accused by his companions of corruption and executed. Abu al-Qasim Samgu bin Wasul al-Miknasi, chief of a branch of the Miknasa tribe, became the leader of the town. This Abu al-Qasim and his descendants formed the Midrarid dynasty.
The Arab geographer Ibn Hawqal visited Spain and the Maghreb between 947 and 951 A.D. According to the account in his Kitab Surat al-Ard, completed around 988 AD, Sijilmasa grew in economic power due to shifting trade routes. At one time trade between Egypt and the Ghana Empire took a direct route across the desert, but because of the harsh conditions, this route was abandoned. Instead caravans passed through the Maghreb to Sijilmasa, then headed south across the Sahara. Sijilmasa's economic wealth is evidenced by Ibn Hawqal's story about a bill issued to a trader in Awdaghust for forty-two thousand dinars from another merchant based out of Sijilmasa. Ibn Hawqal explains that he has never heard of such a large sum of money in all of his travels. Not only was Ibn Hawqal impressed with the volume of trade with the Maghrib and Egypt, Al-Masudi noted gold from Sudan was minted here.
On account of its wealth, the city was able to assert its independence under the Midrarid dynasty, freeing itself from the Abbasid Caliphate as early as 771. Shifting alliances with the Caliphate of Córdoba and the Fatimids of Ifriqiya destabilized the city during the 10th century, beginning with Abd Allah al-Mahdi Billah's visit to the city, the man who was later known as the founder of the Fatimid dynasty. 'Abd Allah, accompanied by his son al-Qa'im, arrived in the Maghreb in 905. 'Abd Allah and his son made their way to Sijilmasa, fleeing persecution by the Abbasids, who not only belonged to the Isma'ili Shi'ite interpretations, but also threatened to the status quo of Abbasid caliphate. According to legend, 'Abd Allah and his son fulfilled a prophecy that the mahdi would come from Mesopotamia to Sijilmasa. They hid among the population of Sijilmasa for four years under the countenance of the Midrar rulers, specifically one Prince Yasa'.
According to al-Bakri, al-Qasim, the son of the mahdi, had miraculous powers and caused a spring to gush forth outside of the city. A Jewish resident of the city witnessed this, and spread the word throughout Sijilmasa that 'Abd Allah was going to attempt to take over the city. At or around the same time, Prince Yasa', the Midrarid ruler, received a letter from the Abbasids in Baghdad, warning him to close his frontiers and be wary of 'Abd Allah. Yasa' was forced to imprison the men he had previously patronized. 'Abd Allah's servant escaped to Kairouan, which at the time was a stronghold for Isma'ilis. The leader of the Isma'ilis in Ifriqiya was Abu 'Abdallah; he quickly mustered an army to rescue his compatriot. On his way to Sijilmasa, he subdued Tahert, the nearby Ibadi Kharijite stronghold under the Rustamid dynasty. The army arrived in the Tafilalt in the latter half of 909, and laid siege to the city. After Yasa' was killed in that year or the next, the Midrar dynasty began a long process of fragmentation that eventually resulted in a hostile takeover by the Maghrawa Berbers, former clients of the Cordoban caliphate.

## List of rulers of Sijilmasa
### Wasulids

* Isa ibn Mazyad al-Aswad 757/8–772
* Abu'l-Qasim Samgu ibn Wasul al-Miknasi 772–784/5
* Abu'l-Wazir al-Yas ibn Abi'l-Qasim 785–790/1
* Abu'l-Muntasir al-Yasa ibn Abi'l-Qasim 790/1–823/4

### Midrarids

* Midrar ibn Yasah, known as al-Muntasir (victorious), 823/4–867
* Maymun ibn Rustumiyya, 867
* Maymun ibn Thakiyya, 867
* Muntasir ibn Yasah, 867 (second time)
* Maymun ibn Thakiyya, 867–877 (second time)
* Muhammad ibn Maymun, 877–883
* Yasah ibn Midrar, 883–909
* Wasul ibn Thakiyya, 909–913
* Ahmad ibn Thakiyya, 913–921
* Muhammad Mutazz ibn Saru, 921–933 / 934
* Muhammad ibn Muhammad, 933 / 934–942 / 943
* Samgu ibn Muhammad, 942/943
* Muhammad ibn Wasul 942 / 943–958
* Samgu ibn Muhammad (Muntasir Billah), 958–963
* Abd Allah ibn Muhammad, 963–976