Founders of the Idrisid state: Idris I and Idris II By the second half of the 8th century the westernmost regions of the
Maghreb, including present-day Morocco, had been effectively independent of the
Umayyad Caliphate since the
Khariji-led
Berber revolts that started in 739–40. The
Abbasid Caliphate after 750 had no more success in re-establishing control over Morocco. who traced his ancestry back to
Ali ibn Abi Talib (died 661) The Awraba tribe had supported
Kusayla in his struggle against the
Ummayad armies in the 670s and 680s. By the second half of the 8th century they had settled in northern Morocco, where their leader Ishak had his base in the Roman town of Volubilis. By this time the Awraba were already Muslim, but lived in an area where most tribes were either Christian, Jewish,
Khariji or pagan. The Awraba seem to have welcomed a Sharifi imam as a way to strengthen their political position. Idris I, who was very active in the political organization of the Awraba, began by asserting his authority and working toward the subjugation of the Christian and Jewish tribes. In 789 he founded a settlement south east of Volubilis, called
Medinat Fas. In 791 Idris I was poisoned and killed by an Abbasid agent. Even though he left no male heir, shortly after his death, his wife Lalla Kanza bint Uqba al-Awrabi, bore him his only son and successor,
Idris II. Idris' loyal Arab ex-slave and companion Rashid brought up the boy and took on himself the regency of the state, on behalf of the Awraba. In 801 Rashid was killed by the
Abbasids. In the following year, at the age of 11 years, Idris II was proclaimed imam by the Awraba. Yahya was given Hiṣn Daī (a site probably near modern
Beni Mellal). Hamza was given Walili. 'Ubayd Allah (or 'Abd Allah) was given the south, including the territory of the Lamta tribes and a town named
Tamdult. Soon after this territorial division Isa revolted against his brother Muhammad. Muhammad entrusted his other brother Umar to punish him. Umar successfully drove Isa from power, who was forced to take refuge in Chellah., minted at al-'Aliyah (
Fes),
Morocco, 840 CE. The coin features the name of
Ali: a son-in-law of
Muhammad, the fourth
Caliph, and an ancestor of the Idrisids.|alt=During this time
Islamic and
Arabic culture gained a stronghold in the towns and Morocco profited from the
trans-Saharan trade, which came to be dominated by Muslim (mostly Berber) traders. The city of Fes also flourished and became an important religious center. or 921. He was succeeded by his cousin Musa ibn Abul 'Afiya, who had already been given charge over the rest of the country. The Idrisid
Hassan I al-Hajam, a grandson of al-Qasim, managed to wrest control of Fez from 925 but in 927 Musa returned, captured Hassan and killed him, marking the last time the Idrisids held power in Fes. From Fes, the Miknasa began pursuing the Idrisid family across Morocco. The family took refuge at the fortress of
Hajar an-Nasr in northern Morocco, where the Miknasa besieged them. Soon after, however, civil war broke out among the Miknasa when Musa switched allegiance to the
Umayyads of Cordoba in 931 in an attempt to gain more independence. The Fatimids sent Humayd ibn Yasal (or Hamid), the nephew of Masala ibn Habus, to confront Musa, defeating him in 933 and forcing him to fall back into line. The Idrisids took advantage of the situation to break the siege of their fortress and defeat the Mikanasa Zenata troops. Once the Fatimids were gone, however, Musa once again threw off their authority and recognized the Umayyad caliph. The Fatimids sent their general Maysur to confront him again, and this time he fled. He was pursued and killed by the Idrisids. After this Idrisids settled among the
Jbala tribes in the Rif region of north-west Morocco where they partially rebuilt their power base from Hajar an-Nasr, alternately acknowledging either the
Umayyads of Cordoba (under
Abd ar-Rahman III) or the Fatimids as overlords.
Al-Qasim al-Gannun ibn Muhammad ruled here from 938 until 948 in the name of the Fatimids. His son and successor, Ahmad, known as
Abul-'Aysh, recognized the Umayyads instead but ran afoul of them when he refused to let them occupy Tangier. He was besieged there and forced to retreat, retaining only the areas around
al-Basra and Asilah while the Umayyads occupied the rest of northern Morocco. He eventually left for Al-Andalus, leaving his brother
Hasan ibn al-Qasim al-Gannun as the new leader in 954. In 958 the Fatimids sent a new general,
Jawhar, to invade Morocco. His success forced the Idrisids to again accept Fatimid overlordship. Soon afterwards, however, when Jawhar and the Fatimids were busy taking control of Egypt, the Umayyads made a comeback. In 973 their general, Ghalib, invaded Morocco. The Idrisids were expelled from their territories and al-Hasan, along with many other Idrisids or their sons, were taken as hostages to Cordoba in 974. The remaining Idrisids in Morocco acknowledged Umayyad rule. Al-Hasan was later expelled from Cordoba and fled to Egypt, which was now under Fatimid rule. In 979
Buluggin ibn Ziri, the Fatimid governor of Ifriqiya (after the Fatimid Caliphs had their capital to
Cairo), returned to defeat the Umayyads and impose Fatimid overlordship in the western Maghreb again. In 985 he returned to Morocco with Fatimid support, but that same year he was defeated by another Umayyad general sent by
al-Mansur and then assassinated on the way to Cordoba. This brought a final end to the Idrisid dynasty. The Umayyads kept control over northern Morocco until their caliphate's collapse in the early 11th century. Following this, Morocco was dominated by various Zenata Berber tribes. Until the rise of the
Sanhaja Almoravids later in the century, the
Maghrawa controlled
Fes,
Sijilmasa and
Aghmat while the
Banu Ifran ruled over Tlemcen,
Salé (Chellah), and the
Tadla region. == Religion ==