▁the ▁B arg h aw ata . ▁ ▁According ▁to ▁medieval ▁legend , ▁Id ris ▁ibn ▁Ab dal lah ▁had ▁fled ▁to ▁Mor oc co ▁after ▁the ▁Abb as ids ' ▁mass acre ▁of ▁his ▁tribe ▁in ▁Ira q . ▁He ▁convinced ▁the ▁Aw ra ba ▁Ber ber ▁tribes ▁to ▁break ▁their ▁alleg iance ▁to ▁the ▁distant ▁Abb as id ▁cal i ph s ▁in ▁Bag hd ad ▁and ▁he ▁founded ▁the ▁Id ris id ▁dynast y ▁in ▁ 7 8 8 . ▁The ▁Id ris ids ▁established ▁F es ▁as ▁their ▁capital ▁and ▁Mor oc co ▁became ▁a ▁centre ▁of ▁Muslim ▁learning ▁and ▁a ▁major ▁regional ▁power . ▁The ▁Id r iss ids ▁were ▁ou sted ▁in ▁ 9 2 7 ▁by ▁the ▁F at im id ▁C ali ph ate ▁and ▁their ▁Mik n asa ▁al lies . ▁After ▁Mik n asa ▁broke ▁off ▁relations ▁with ▁the ▁F at im ids ▁in ▁ 9 3 2 , ▁they ▁were ▁removed ▁from ▁power ▁by ▁the ▁Mag h raw a ▁of ▁S ij il mas a ▁in ▁ 9 8 0 . ▁ ▁D ynast ies ▁ ▁From ▁the ▁ 1 1 th ▁century ▁on wards , ▁a ▁series ▁of ▁Ber ber ▁dynast ies ▁arose . ▁Under ▁the ▁Al mor avid ▁dynast y ▁and ▁the ▁Al m oh ad ▁dynast y , ▁Mor oc co ▁domin ated ▁the ▁Mag h reb , ▁much ▁of ▁present - day ▁Spain ▁and ▁Portugal , ▁and ▁the ▁western ▁Mediter rane an ▁region . ▁From ▁the ▁ 1