The story begins Idrissides, when Shiite Arab prince of the family of Ali (the fourth Caliph of Islam), Idris Ibn 'Abd Allah al-Kamil and his freedman Ben Rachid El Morched Koreichi, took refuge in the Middle Atlas. Fleeing the threat of the Abbasids (who had massacred Alides and their supporters in the Shiite battle Fakh near Mecca), they stay in Egypt before moving to Walilah (Volubilis) under the protection of the Berber tribe Awarbas. Managing to rally the tribes to his cause, Imam Idriss is invested and founded the city of Fez in 789 under the name of Idris I. This is the beginning of the dynasty Idrissides.
Al Qaraouiyyine Fes, home to a university founded in the ninth century under the reign of Idrissides
Idris I is assassinated by an emissary of the Abbasid Caliph Harun al-Rashid in Baghdad, a Zindhi Sulayman al. Not suspecting that the wife of Idris I (Kenza) is pregnant, Haroun al-Rashid believes that the threat of the emergence of a power Alid west of the Maghreb is conquered. But a few months later, born Idris II. His education was entrusted to the freedman of his father Rashid who provides a kind of regency. Eleven years later, he was proclaimed Imam believers of Fez. Over time, his wisdom and direction for state policy, he managed to unite most of the tribes, the number of his followers increased and the power of his army now work (in which engage Kaisites from of the northern tribes of the Arabian Peninsula) develops. The kingdom Idrisid and includes any portion of territory extending from east to Tlemcen Souss Gharb south and west. It seems that Idrisid dynasty, at least in its early stages, has professed the Shia and more specifically zaïdisme, reputed to be the most moderate chiites17 rites. Idrissid successive princes pass quickly however Sunnism.
Feeling cramped Walilah Idriss II left the ancient Roman city to Fez, where he founded Kairouan district on the left bank (Idris I had settled on the right bank, the Andalusian quarter). Kairouan is the powerful families from Eastern Arab and Arab-Persian (from Khorasan) established Ifriqya from the Abbasid era. They were expelled from Kairouan because of political persecution that they inflict Aghlabids. Andalusians who settled in Fez are in turn opponents of Umayyad Cordoba from the suburbs (including the suburb of Rabad, hence the name Rabadis assigned to elements of the first wave of immigration from Al -Andalus) 18. The kingdom knows Idrisid generally an important phase of urbanization, illustrated by the creation of new towns like Sale, Wazzequr and Basra, the latter inspired by the Basra Iraq. These urban centers are hotbeds of diffusion of Arab culture and Islam vectors.
At the same time, the Vikings came from Scandinavia and the far conducted by Hastings and Prince Swedish Björn Ironside, attracted by the wealth potential and potential around the Strait of Gibraltar and the Western Mediterranean, are distinguished by their devastating raids on the coasts northern Morocco (especially in areas of Asilah and Nador) 19. The Andalusian historian and geographer Al-Bakri designate the Viking invaders by the term "Majus" and chronicling their abuses particularly against the Emirate of Nekor in Rif20.
In 985, the Idrissides lose political power in Morocco and massively exiled Al-Andalus. Installed in Malaga, they gradually recover their power, to the point of generating a dynasty during the Taifa era, the Hammudites. The latter argue even function in Cordoba Caliphate instead fallen in Umayyad 101,621.