[4]: 52 [5]: 83–84 Fleeing the Abbasid Caliphate to the east in the aftermath of the Battle of Fakhkh, Idris I first established himself in 788 at Volubilis in present-day Morocco with the help of local Berber allies.
The Idrisids were definitively expelled from Fez in 927, but held onto to a reduced territory in the north of Morocco from their base at Hajar an-Nasr.
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.
[4]: 41 The overthrow of eastern authority meant that Morocco was controlled by various local Berber tribes and principalities which emerged around this time, such as the Barghwata Confederacy on the Atlantic coast and the Midrarid Emirate in Sijilmasa.
[1][5]: 81 After the Battle of Fakhkh, near Mecca, between the Abbasids and supporters of the descendants of Muhammad, Idris ibn Abdallah fled to the Maghreb.
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.
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.
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.
[4]: 51 Even though he had spread his authority across much of northern Morocco, as far west as Tlemcen, Idris I had been completely dependent on the Awraba leadership.
Idris reacted by having his former protector Ishak killed, and in 809 moved his seat of government from the Awraba dominated Walili to Fes, where he founded a new settlement named Al-'Aliya.
Under his son and successor Muhammad (828–836) the kingdom was divided amongst seven of his brothers, whereby eight Idrisid statelets formed in Morocco and western Algeria.
[7] Isa was given control of the coastal Tamesna regions near the Bou Regreg, including Shallah (Chellah), and was based at Wazeqqūr (a town near modern-day Khenifra).
His son Ali ibn Muhammad inherited his position and ruled for 13 years (836–849) in a competent manner, ensuring the stability of the state.
[7]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.
[7] In 868, under the leadership of the Abd al-Razzaq the Berber Khariji Sufri tribes of Madyuna, Ghayata and Miknasa of the Fes region formed a common front against the Idrisids.
[7] 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.
[7] 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.
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.
In 985[12] 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.
[5]: 91 [4]: 82 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.
[5]: 91 According to Encyclopædia Britannica, "although Idrīs I had Shīʿite sympathies, the state founded by his son was Sunni in matters of religious doctrine.
[7] In the 11th century, an Idrisid family descended from Umar (son of Idris II), the Hammudids, were able to gain power in several cities of northern Morocco and southern Spain.
[28] From the 14th century, local writers began to portray the Idrisids as the starting point of an Islamic Maghrib al-Aqsa ("Furthest West", corresponding to present-day Morocco[29]).
[30] In the national narratives of modern Morocco, the Idrisids are often portrayed as the first Moroccan dynasty and as the start of an uninterrupted tradition of monarchy to the present day.