Every great Moroccan story starts somewhere, and the story of the idrisid dynasty morocco begins in the oldest streets of Fes. Before the Almoravids built Marrakech, before the Almohads raised their minarets, a fugitive prince from the east arrived in the hills of the north and founded the first Moroccan state. That state gave the country its first capital, its first dynasty and, in time, its oldest university.
This article follows the story of the idrisid dynasty morocco from the beginning: the flight of Idris I, the disputed founding of Fes, the city-building of Idris II, and the university of al-Qarawiyyin. It also tells you where the Idrisid past is still visible today, so you can walk it yourself. For the wider sweep of Moroccan history, start with our pillar guide, A Brief History of Morocco: From the Mauretanian Kings to Today.
- The Idrisid Dynasty Morocco: A Kingdom Born from Exile
- Idris I and the Founding of a New State
- The Founding of Fes: 789 or 808?
- Idris II and the City on Two Banks
- Al-Qarawiyyin: The University That Outlived Its Dynasty
- Religion, Trade and a New Moroccan Identity
- The Idrisid Dynasty Morocco at Its Height and Its Decline
- Where to See Idrisid Fes Today
- Frequently Asked Questions
- Conclusion: Why the Idrisids Still Matter
The Idrisid Dynasty Morocco: A Kingdom Born from Exile
The idrisid dynasty morocco was born out of defeat. In 786, the Abbasid caliphate crushed an Alid revolt at the Battle of Fakhkh, near Mecca. Among the survivors was Idris ibn Abdallah, a great-great-grandson of the Prophet Muhammad through his grandson al-Hasan. Staying in the east meant death, so Idris fled west, travelling through Egypt and Libya until he reached the far Maghreb in 789.
He did not arrive as a conqueror with an army. The founder of the idrisid dynasty morocco arrived as a single man with a famous name, and that was enough. The Berber tribes of northern Morocco were Muslim in name but largely outside the control of any caliph, and they were ready for a leader who carried religious authority without carrying Abbasid taxes. The Awraba tribe, settled around the Roman ruins of Walila, welcomed him first, and their chief Ishaq ibn Muhammad gave him protection and a base.
What followed was a political bargain that would repeat throughout Moroccan history: a Sharif, a descendant of the Prophet, lending sacred legitimacy to Berber tribal power. The idrisid dynasty morocco fused the two, and the result was the first state that can properly be called Moroccan, independent of Baghdad and of Cordoba alike. Read about the site where it all began in our Volubilis guide.
Idris I and the Founding of a New State
Idris I ruled only three years, from 788 to 791, yet those three years set the pattern for everything that followed. The first ruler of the idrisid dynasty morocco united the tribes of the north, from the Rif mountains to the Atlantic coast near present-day Tangier, and he began to build the institutions of a state: a court, an army drawn from loyal tribes, and a mint striking silver dirhams in his own name.
The coins matter more than they sound. A ruler who mints his own coins is declaring independence in the language every trader understands, and dirhams of the idrisid dynasty morocco soon circulated across the western Maghreb. He also founded a settlement on the site of what would become Fes, a camp and market on the banks of the Oued Fes, though the city itself was still to come.
His death in 791 is one of the first disputed dates in Moroccan history. The traditional account says the Abbasid caliph Harun al-Rashid sent an agent who poisoned him, a story that fits the politics of the time but cannot be proven. What is certain is that the founder of the idrisid dynasty morocco died young, leaving a pregnant wife and no adult heir, and that his loyal freedman Rashid held the young state together until the child was born. For the scholarly background, see the Idrisid dynasty entry on Wikipedia.
The Founding of Fes: 789 or 808?
Ask when Fes was founded and you will get two answers, and both are honest. Some sources date the founding to 789, when Idris I established his camp on the river. Others date it to 808, when his son Idris II moved the capital there and built a proper city. The founding of Fes is dated 789 or 808 depending on the source, and the honest answer is that both dates describe real events.
This is the first correction most English summaries get wrong. They credit Idris I alone with founding Fes, as if a camp were a city. The truth is plainer and more interesting: Idris I chose the site, but Idris II built the city. The distinction matters, because it tells you what kind of ruler Idris II was — not a caretaker of his father’s work but a founder in his own right.
The site itself explains the choice the idrisid dynasty morocco made. The Oued Fes offered water, the surrounding hills offered defence, and the location sat on the routes between the Atlantic coast, the Middle Atlas and the Algerian east. A capital here could tax trade, shelter scholars and hold the tribes together, and that is exactly what it did for the next twelve centuries.
Idris II and the City on Two Banks
The second ruler of the idrisid dynasty morocco, Idris II, is commonly said to have reigned from 803 to 828, though those dates are not settled and some chronicles shift them by a few years either way. What the sources agree on is the scale of his achievement. As a young man he took power from his regent, moved the capital from Walila to the new site on the Oued Fes, and turned a camp into a capital with walls, mosques, markets and palaces.
Idris II built the capital of the idrisid dynasty morocco on both banks of the river, and that single decision shaped the city for centuries. On one bank rose the quarter of the Kairouanese, families who had fled Tunisia; on the other, the quarter of the Andalusis, refugees from Cordoba. Each community built its own great mosque — al-Qarawiyyin on one side, the Andalusian mosque on the other — and the rivalry between them drove the city to grow faster than any single plan could have managed.
Two Banks, Two Peoples
The two quarters were more than neighbourhoods; they were two different Moroccos learning to live in one city. The Kairouanese brought the scholarship and legal traditions of Ifriqiya, while the Andalusis brought the crafts, music and urban manners of Cordoba. Their competition filled Fes with mosques, schools, baths and fondouks, and their eventual merging produced the distinctive Fassi culture that still sets the city apart today.
From Walila to Fes
The move from Walila was also a statement of independence. Walila was a Roman city, impressive but foreign, and its ruins reminded everyone of an empire that had gone. Fes was new, Islamic and Moroccan, built on empty ground by a Moroccan dynasty. When the court of the idrisid dynasty morocco moved, the centre of power in the far Maghreb moved with it, and it has never really moved back.
Al-Qarawiyyin: The University That Outlived Its Dynasty
In 859, some fifty years after the founding of Fes, a wealthy woman from Kairouan named Fatima al-Fihri spent her inheritance building a mosque in the Kairouanese quarter. That mosque became the University of al-Qarawiyyin, recognised by UNESCO and the Guinness Book of Records as the oldest continuously operating university in the world. It is the crown of the idrisid dynasty morocco era, and it outlived the dynasty itself by more than a thousand years.
Here is the second correction worth making plainly. The “oldest university” claim belongs to the Idrisid era, but it is not Idrisid state work. Fatima al-Fihri was a private patron, a pious merchant’s daughter spending family money, not a princess carrying out a royal project. The dynasty created the city and the conditions in which such a foundation was possible, but the university itself was a citizen’s gift, and that makes the story better, not worse.

The mosque-university grew into one of the great centres of learning in the Islamic world. Scholars such as Ibn Khaldun and Maimonides are associated with its circles, and its library holds manuscripts from the idrisid dynasty morocco period that are among the oldest in existence. The prayer hall itself is closed to non-Muslim visitors, but you can admire the carved wooden doors and the green-tiled minaret from the street, and the surrounding lanes are the oldest and most atmospheric in the medina. The later Marinid rulers added the great madrasas nearby, which you can read about in our guide to the Marinids, Fes and its madrasas.
Religion, Trade and a New Moroccan Identity
The Idrisids did more than build a city; they gave northern Morocco a religious identity that has lasted ever since. Under the idrisid dynasty morocco, Islam spread beyond the coastal towns into the Rif and the Middle Atlas, carried by scholars and by the prestige of a Sharifian dynasty. The Maliki school of law took root in Fes and became the legal backbone of the country, a position it still holds today.
Trade was the other pillar of the idrisid dynasty morocco. Fes sat on the routes that carried gold from the Sahara, leather and textiles to Andalusia, and scholars and pilgrims in every direction. The city’s tanneries, dyers and metalworkers grew rich serving this trade, and the Idrisid dirham became a trusted currency across the region. A visitor to Fes in the ninth century would have found a city that felt less like a tribal capital and more like a small Cordoba or Kairouan, and that was precisely the point.
This combination — Sharifian legitimacy, Maliki scholarship and long-distance trade — became the template for Moroccan statehood. Every dynasty that followed, from the Almoravids to the Alaouites, would borrow from it, and the idrisid dynasty morocco is best understood as the first draft of a political idea that Morocco has been revising ever since. Our series on the kings of Morocco and its dynasties traces that long line, and this dynasty is where it starts.
The Idrisid Dynasty Morocco at Its Height and Its Decline
At its height under Idris II and his son Muhammad, the idrisid dynasty morocco stretched from the Atlantic to the Moulouya river and south toward the Atlas. Fes was its heart, but the dynasty also held Tangier, the Rif ports and the trading towns of the north. It was the first time a single Moroccan ruler had governed so much territory from a Moroccan capital, and the achievement is easy to understate.
The decline of the idrisid dynasty morocco began with the same problem that weakened many Moroccan dynasties: division among heirs. Muhammad divided the kingdom among his brothers, and the Idrisid lands split into small rival principalities that quarrelled while greater powers gathered. From the east came the Fatimids, from the north the Umayyads of Cordoba, and both treated the Idrisid princes as pieces on a larger board.
The last Idrisid ruler, al-Hasan ibn al-Qasim, died in 974, and the dynasty ended as it had begun — in the shadow of a greater empire’s politics. Yet its legacy was permanent. The Idrisids had proved that Morocco could be ruled from Morocco, by a Moroccan dynasty, and every later dynasty inherited that idea along with the capital they left behind.
Where to See Idrisid Fes Today
The city of the idrisid dynasty morocco is still under your feet when you walk Fes el-Bali, even though most of the buildings you see are younger. The street plan, the two quarters and the sites themselves are the dynasty’s real monument, and the best way to experience them is simply to walk. Entry to the medina is free — you just wander in — and the table below gives you the key stops.
| Place | What to see | Idrisid connection |
|---|---|---|
| Fes el-Bali medina | The two quarters, the river, the old street plan | The city Idris II built on both banks |
| Al-Qarawiyyin | Green-tiled minaret, carved doors, library | Founded 859 in the Idrisid era by Fatima al-Fihri |
| Tomb of Idris II | Mausoleum and mosque near Place Pacha Bouanania | Idris II is buried here; a place of pilgrimage |
| Moulay Idriss Zerhoun | Hilltop town, green-tiled mausoleum | Idris I is buried here, near Walila |
| Volubilis (Walila) | Roman ruins, triumphal arch, mosaics | Where Idris I was welcomed in 789 |
Moulay Idriss Zerhoun, the little white town in the hills near Volubilis, is the most moving Idrisid site of all. Idris I is buried there, and for centuries non-Muslims were not allowed to stay overnight in the town, such was its sanctity. Today you can visit freely, climb to the viewpoint above the mausoleum, and look down over the green roofs toward the ruins of Walila. A few small museums in Fes charge a modest entry fee, typically 20–70 MAD (about $2–7 USD), prices checked November 2026. The medina itself, the tombs and the views cost nothing.

For practical help planning your walk, including where to stay and how to find a good guide, see our Fes travel guide. The medina of Fez is listed by UNESCO as a World Heritage Site, and the UNESCO page for the Medina of Fez is worth reading before you go.
Frequently Asked Questions
Who founded the Idrisid dynasty?
Idris ibn Abdallah founded the idrisid dynasty morocco in 788–789, after fleeing the Abbasid persecution that followed the Battle of Fakhkh. A descendant of the Prophet Muhammad, he was welcomed by the Berber Awraba tribe at Walila and built the first independent Moroccan state.
When was Fes founded?
The founding of Fes is dated 789 or 808 depending on the source, and both dates are defended by serious historians. Idris I established a camp on the site in 789, while his son Idris II built the actual city and moved the capital there in 808.
Is al-Qarawiyyin really the oldest university in the world?
Al-Qarawiyyin, founded in 859 by Fatima al-Fihri, is recognised as the oldest continuously operating university in the world. It was a private religious endowment, not a state project of the idrisid dynasty morocco, but it was founded in Fes during the Idrisid era and grew under the dynasty’s protection.
Where is Idris I buried?
Idris I is buried at Moulay Idriss Zerhoun, the hilltop town near Volubilis that still bears his name. His tomb and mausoleum are a place of pilgrimage, and the town is an easy day trip from Fes or Meknes.
How long did the Idrisid dynasty last?
The idrisid dynasty morocco lasted from 788 to 974, just under two centuries. Its real power was concentrated in the ninth century under Idris II and his immediate successors, and it fragmented into rival principalities after Muhammad ibn Idris divided the kingdom among his brothers.
Can you visit Idrisid sites in Fes today?
Yes. Fes el-Bali, al-Qarawiyyin, the tomb of Idris II and Moulay Idriss Zerhoun are all visitable today, and wandering the medina itself is free. Non-Muslim visitors cannot enter the prayer halls of mosques, but the streets, doors, minarets and viewpoints are open to everyone.
Conclusion: Why the Idrisids Still Matter
The idrisid dynasty morocco lasted less than two centuries, and its last rulers were minor princes caught between greater empires. Yet its achievement was permanent: it founded Fes, made Morocco a state rather than a collection of tribes, and joined Sharifian legitimacy to Berber power in a formula every later dynasty would use. When you walk the lanes of Fes el-Bali, you are walking the first draft of Morocco itself, and that is why the Idrisids, forgotten by many visitors, deserve to be remembered first.