Midrarid dynasty

[3] 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.

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.

Abu al-Qasim Samgu bin Wasul al-Miknasi, chief of a branch of the Miknasa tribe, became the leader of the town.

[citation needed] The Arab geographer Ibn Hawqal visited Spain and the Maghreb between 947 and 951 A.D.[5] According to the account in his Kitab Surat al-Ard, completed around 988 AD, Sijilmasa grew in economic power due to shifting trade routes.

[citation needed] 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.

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.

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.