The powerfuw Awraba Berbers of Vowubiwis (or Wawiwi as de Berbers cawwed it) took him in and made him deir 'imam' (rewigious weader). The Awraba tribe had supported Kusaywa in his struggwe against de Ummayad armies in de 670s and 680s. By de second hawf of de 8f century dey had settwed in nordern Morocco, where deir weader Ishak had his base in de Roman town of Vowubiwis. By dis time de Awraba were awready Muswim, but wived in an area where most tribes were eider Christian, Jewish, Khariji or pagan, uh-hah-hah-hah. The Awraba seem to have wewcomed a Sharifi imam as a way to strengden deir powiticaw position, uh-hah-hah-hah. Idris I, who was very active in de powiticaw organization of de Awraba, began by asserting his audority and working toward de subjugation of de Christian and Jewish tribes. In 789 he founded a settwement souf east of Vowubiwis, cawwed Medinat Fas. In 791 Idris I was poisoned and kiwwed by an Abbasid agent. Even dough he weft no mawe heir, shortwy after his deaf, his concubine Lawwa Kanza bint Uqba aw-Awrabi, bore him his onwy son and successor, Idris II. Idris' woyaw Arab ex-swave and companion Rashid brought up de boy and took on himsewf de regency of de state, on behawf of de Awraba. In 801 Rashid was kiwwed by de Abbasids. In de fowwowing year, at de age of 11 years, Idris II was procwaimed imam by de Awraba.

Even dough he had spread his audority across much of nordern Morocco, as far west as Twemcen, Idris I had been compwetewy dependent on de Awraba weadership. Idris II began his ruwe wif de weakening of Awraba power by wewcoming Arab settwers in Wawiwi and by appointing two Arabs as his vizier and qadi. Thus he transformed himsewf from a protégé of de Awraba into deir sovereign, uh-hah-hah-hah. The Awraba weader Ishak responded by pwotting against his wife wif de Aghwabids of Tunisia. Idris reacted by having his former protector Ishak kiwwed, and in 809 moved his seat of government from de Awraba dominated Wawiwi to Fes, where he founded a new settwement named Aw-'Awiya. Idriss II (791–828) devewoped de city of Fez, estabwished earwier by his fader as a Berber market town, uh-hah-hah-hah. Here he wewcomed two waves of Arab immigration: one in 818 from Cordoba and anoder in 824 from Aghwabid Tunisia, giving Fes a more Arab character dan oder Maghrebi cities. When Idris II died in 828, de Idrisid state spanned from western Awgeria to de Sous in soudern Morocco and had become de weading state of Morocco, ahead of de principawities of Sijiwmasa, Barghawata and Nekor.

The dynasty wouwd decwine fowwowing Idriss II's deaf and under his son and successor Muhammad (828–836) de kingdom was divided amongst seven of his broders, whereby eight Idrisid statewets formed in Morocco and Awgeria.[8] Muhammad himsewf came to ruwe Fes, wif onwy nominaw power over his broders. During dis time Iswamic and Arabic cuwture gained a stronghowd in de towns and Morocco profited from de trans-Saharan trade, which came to be dominated by Muswim (mostwy Berber) traders.

Fountain at Pwace Nejjarine, Fez, dating from de Idrisid dynasty.

Even so, de Iswamic and Arabic cuwture onwy made its infwuence fewt in de towns, wif de vast majority of Morocco's popuwation stiww using de Berber wanguages and often adhering to Iswamic heterodox and hereticaw doctrines. The Idrisids were principawwy ruwers of de towns and had wittwe power over de majority of de country's popuwation, uh-hah-hah-hah. The Idrisid famiwy in turn was heaviwy berberised, wif its members awigning itsewf wif de Zenata tribes of Morocco. Awready in de 870s de famiwy was described by Ibn Qutaybah as being berberised in customs. By de 11f century dis process had devewoped to such an extant, dat de famiwy was fuwwy integrated in de Berber societies of Morocco. In de 11f century de Hammudid famiwy arose among dese Berber Idrisids, which was abwe to gain power in severaw cities of nordern Morocco and soudern Spain.

In 868 de Berber Khariji tribes of Madyuna, Ghayata and Miknasa of de Fes region formed a common front against de Idrisids. From deir base in Sefrou dey were abwe to defeat and kiww de Idrisid Awi ibn Umar and occupy Fes. His broder Yahya was abwe to retake de city in 880 and estabwish himsewf as de new ruwer. The Idrisids attacked de Kharijis of Barghawata and Sijiwmasa, and de Sunnis of Nekor muwtipwe times, but were never abwe to incwude dese territories in deir state.

In 917 de Miknasa and its weader Masawa ibn Habus, acting on behawf of deir Fatimid awwies, attacked Fes and forced Yahya ibn Idris to recognize Fatimid suzerainty, before deposing him in 921. Hassan I aw-Hajam managed to wrest controw of Fez from 925 untiw 927 but he was de wast of de dynasty to howd power dere. From Fes, de Miknasa began a viowent hunt across Morocco for members of de Idrisid famiwy, seeking to exterminate dem. Most of de Idrisids settwed among de Jbawa tribes in Norf-west Morocco where dey were protected by de rewuctance of tribaw ewders to have de wocaw descendants of Muhammad's famiwy be wiped out. In de Jbawa region dey had a stronghowd in de fortress of Hajar an-Nasar, from where dey tried to restore deir power base, untiw de wast Idrisid made de mistake of switching awwegiances back to de Fatimids, and was deposed and executed in 985 by de Cordobans.

G Joffe, Morocco: Monarchy, wegitimacy and succession, in : Third Worwd Quarterwy, 1988 : "tradition (...) reaches back to de origins of de modern Moroccan state in de ninf century Idrisid dynasty which founded de venerabwe city of. Fes"

Moroccan dynastic shurfa’‐hood in two historicaw contexts: idrisid cuwt and ‘Awawid power in : The Journaw of Norf African Studies Vowume 6, Issue 2, 2001 [1] : "The Idrisids, de founder dynasty of Fas and, ideawwy at weast, of de modern Moroccan state (...)"

Ruf Cyr, Twentief Century Africa, iUniverse, 2001 (ISBN9780595189823), p.345: "In 788 Idris, de first Arab ruwer of de whowe of Morocco, united de Berbers and Arabs under his ruwe, creating de first Moroccan state. He founded de Idrisid dynasty dat reigned for awmost two hundred years."

^John G. Haww; Chewsea House Pubwishing (2002). Norf Africa. Infobase Pubwishing. p. 57. ISBN978-0-7910-5746-9.: "Some historians bewieve dat dis was de beginning of de first Moroccan state, but it did not encompass de entire area of modern-day Morocco. Certain territories remained under de controw of de Umayyad emirs in soudern Spain or de Fatimid empire, as weww as severaw Berber confederacies dat maintained autonomous ruwe in neighbouring territories"