Morocco
According to medieval legend, Idris ibn Abdallah had fled to Morocco after the Abbasids massacre of his tribe in Iraq. He convinced the Awraba Berber tribes to break their allegiance to the distant Abbasid caliphs in Baghdad and he founded the Idrisid dynasty in 788. The Idrisids established Fes as their capital and Morocco became a centre of Muslim learning and a major regional power. The Idrissids were ousted in 927 by the Fatimid Caliphate and their Miknasa allies. After Miknasa broke off relations with the Fatimids in 932, they were removed from power by the Maghrawa of Sijilmasa in 980.