A Brief History of Morocco: From the Mauretanian Kings to Today

Most short summaries of the history of Morocco begin in 1912, with the French protectorate. That is like telling the story of a very old man and starting with his retirement. Morocco is one of the oldest continuously existing states on earth: its monarchy traces an unbroken line back to Idris I, proclaimed in 788, and the land beneath that state has been inhabited for hundreds of thousands of years. Kings, empires and invaders have come and gone, yet the thread was never cut — the country changed rulers, religions and capitals without ever ceasing to be itself.

This is that longer story, told the way we tell it at home: with pride, but also with honesty about what is certain and what historians still argue over. If you are planning to stand in these places yourself, pair this page with our Morocco travel guide for first-time visitors — the ruins, medinas and mosques below are all still there to be walked through.

History of Morocco: The Roman ruins of Volubilis in Morocco, with ancient columns, triumphal arch and mosaics surrounded by green hills

Before History: Jebel Irhoud and the Amazigh Roots

Human history in Morocco begins earlier than almost anywhere else. At Jebel Irhoud, near Safi, fossils of early Homo sapiens were re-dated in 2017 to around 300,000 years old — among the oldest known remains of our species anywhere in the world. Long before there was a Morocco, there were people here, hunting and gathering between the Atlantic and the Sahara.

The indigenous people of this land are the Amazigh — the “free people,” long known to outsiders as Berbers. Amazigh communities farmed, herded and traded across North Africa for millennia, leaving rock engravings in the desert and a language, Tamazight, that is still spoken today and is now an official language of the kingdom. From around the 12th century BC, Phoenician sailors founded trading posts on the coast — Lixus, Tingis (Tangier) and Mogador (Essaouira) among them — and Carthage later extended its influence. The Amazigh were never passive in this story: by the last centuries BC they had built kingdoms of their own.

The Mauretanian Kingdom: Juba II and Cleopatra Selene

The first great Moroccan state was the Kingdom of Mauretania. Its kings dealt with Rome as allies, rivals and in-laws — King Bocchus I famously handed the Numidian king Jugurtha over to the Romans in 105 BC. The kingdom’s most remarkable chapter came in 25 BC, when the emperor Augustus placed Juba II on its throne. Raised and educated in Rome after his father Juba I’s defeat, Juba II was a scholar-king who wrote books on geography and natural history, and he married Cleopatra Selene — the daughter of Mark Antony and Cleopatra VII of Egypt.

From their court, Mauretania became a prosperous, cultivated kingdom. Volubilis, in the fertile plains near today’s Meknes, flourished as a royal city of olive groves, grand houses and fine mosaics; Tingis guarded the strait as its great port. Juba II’s son Ptolemy inherited the throne, but the emperor Caligula had him executed in AD 40. Within a few years Claudius annexed the kingdom, splitting it into two Roman provinces — Mauretania Tingitana, governed from Tingis, and Mauretania Caesariensis to the east.

Bab Bou Jeloud, the ornate blue and green tiled gate at the entrance to the old medina of Fes el Bali in Morocco

Rome, Vandals and Byzantines

Under Rome, the Volubilis region exported olive oil, grain and garum across the empire, and its wealthy homes were decorated with mosaics you can still see in place today. But Roman power in the far west was always thinner than the maps suggest. Around AD 285, under Diocletian, Rome pulled back to a coastal strip around Tangier and the strait, leaving the interior to Amazigh principalities that governed themselves.

When the Vandals swept into North Africa in 429, their grip on the far west was looser than in the east, and a century later the Byzantines under Belisarius retook coastal strongpoints, including Septem — today’s Ceuta. Through all of this, the Amazigh kingdoms of the mountains and plains carried on, largely independent, waiting for the next great change to arrive from the east.

The Arrival of Islam: Idris I, Idris II and the Founding of Fes

Arab armies reached Morocco in the late 7th century; tradition remembers the commander Uqba ibn Nafi riding into the Atlantic around 682 and declaring that only the ocean stopped him. In 711 the Amazigh general Tariq ibn Ziyad crossed the strait to Iberia — Gibraltar still carries his name, Jabal Tariq, “Tariq’s mountain.” The Amazigh adopted Islam, but on their own terms, rising in a great revolt in 740 against the caliphs in Damascus.

The turning point came in 788 with the arrival of Idris ibn Abdallah, a descendant of the Prophet Muhammad through his grandson Hasan, fleeing Abbasid persecution. Welcomed by the Awraba tribe at Walili — Roman Volubilis — he was proclaimed imam, and that proclamation is the founding moment of the Moroccan state. Idris I was assassinated in 791, according to tradition by an Abbasid agent, but his son was born after his death and raised to succeed him.

Idris II founded Fes in 808–809 and made it his capital. The city grew fast, absorbing waves of refugees from Córdoba and Kairouan whose quarters — the Andalusiyyin and the Qarawiyyin — still structure the old medina. In 859, Fatima al-Fihri, a woman of that Kairouan community, used her inheritance to found the Al-Qarawiyyin mosque and school. It is often described, including by UNESCO and Guinness World Records, as the oldest continuously operating educational institution in the world — and it still functions in the heart of Fes el-Bali today.

The Almoravids: Marrakech and the Rescue of al-Andalus

In the 11th century, a new power rose among the Sanhaja tribes of the Sahara, bound together by the austere reformer Abdallah ibn Yasin. The exact year of Ibn Yasin’s death is disputed — historians give 1058 or 1059 — but his movement, the Almoravids, outlived him. Under Yusuf ibn Tashufin they founded Marrakech around 1070 as their capital, united Morocco, and then crossed into Spain, where at Zallaqa in 1086 Yusuf crushed Alfonso VI of Castile and preserved Muslim al-Andalus for another generation. Their empire stretched from Senegal to the Ebro.

The Almohads: An Empire from Tripoli to the Atlantic

The Almoravids were overthrown by a still greater movement: the Almohads, launched by Ibn Tumart, a Masmuda reformer who proclaimed himself Mahdi in 1121. His successor Abd al-Mu’min took Marrakech in 1147 and built the largest empire Morocco has ever ruled — from Tripoli in the east to the Atlantic, and deep into Iberia. The Almohad century left Morocco its most beloved skyline: the Koutoubia mosque in Marrakech, the Hassan Tower in Rabat and the Giralda in Seville all rose under their rule. Defeat by the Christian kingdoms at Las Navas de Tolosa in 1212 began a long decline, and the last Almohad caliph was killed in 1269.

The Koutoubia mosque minaret in Marrakech glowing in warm golden hour light against a clear evening sky

The Marinids: The Age of the Madrasas

The Marinids, a Zenata Amazigh dynasty, took Fes in 1248 and Marrakech in 1269. Unable to hold an empire in Spain, they poured their wealth into Morocco itself: they founded Fes el-Jdid in 1276 and filled the cities with exquisite madrasas — religious colleges such as the Bou Inania, whose carved plaster, cedarwood and tilework remain the high point of Moroccan art. But the dynasty slowly weakened, Portugal seized Ceuta in 1415, and the Marinids’ Wattasid successors could not stop the fragmentation of the country.

The Saadians: The Battle of the Three Kings and a Golden Age

Unity returned with the Saadians, sharifs — claimants of descent from the Prophet — who rose from the Draa valley, took Marrakech in 1549 and Fes in 1554. Their defining moment came in 1578 at the Battle of the Three Kings near Ksar el-Kebir: a Portuguese invasion army was annihilated, King Sebastian of Portugal was killed, the reigning Saadian sultan also died on the field, and his brother Ahmad al-Mansur emerged as sultan.

Al-Mansur, “the Victorious,” turned the victory into a golden age: ransoms and sugar enriched his court, he built the sumptuous El Badi palace in Marrakech, and in 1591 his expedition crossed the Sahara and conquered the Songhai empire of Timbuktu and Gao. After his death in 1603, his sons’ civil wars undid much of it.

The Alaouites: From Moulay Ismail to Today

The present royal dynasty, the Alaouites, are also sharifs, from the Tafilalet oases. Moulay Rashid reunified the country in the 1660s, and his brother Moulay Ismail (1672–1727) built Meknes into a vast imperial capital during one of the longest reigns in Moroccan history. In the following century Morocco traded and negotiated with the world: Mohammed III founded Essaouira as a royal port, and Morocco was among the first states to recognise the independence of the United States, signing a treaty of friendship in 1786 that remains the longest unbroken treaty in American history.

The 19th century brought growing European pressure — defeat by France at Isly in 1844, war with Spain in 1859–60 — and in 1912 Sultan Abd al-Hafid signed the Treaty of Fes, establishing the protectorate. Honesty requires precision here: Morocco was never formally annexed as a colony; it was divided into French and Spanish protectorate zones, with Tangier international, while the sultan remained on the throne. Resident-General Lyautey built new European cities beside the old medinas rather than demolishing them — which is why Fes and Marrakech survive as they do.

Resistance was immediate and continuous, from Abd el-Krim’s Rif Republic, which destroyed a Spanish army at Annual in 1921, to the nationalist movement that rallied around Sultan Mohammed V. When France exiled Mohammed V to Madagascar in 1953, the country rose; he returned in triumph in 1955, and Morocco regained its independence in 1956.

Mohammed V was succeeded in 1961 by Hassan II, who ruled through decades of nation-building and tension, including the Green March of 1975 into the Western Sahara. Since 1999, Mohammed VI has led a programme of economic development and gradual reform, including a new constitution in 2011. Through every change since 788, the institution at the centre of the state — the sharifian monarchy — has endured, which is precisely what makes Morocco’s history unusual.

The History of Morocco: Dynasties at a Glance

Dynasty Dates Capital Legacy
Kingdom of Mauretania c. 285 BC – AD 44 Volubilis / Tingis Juba II and Cleopatra Selene; Roman-era prosperity
Idrisids 788–974 Fes Founding of the Moroccan state and of Fes; Al-Qarawiyyin (859)
Almoravids 1040–1147 Marrakech Founded Marrakech; united Morocco and al-Andalus; victory at Zallaqa
Almohads 1121–1269 Marrakech Largest Moroccan empire; Koutoubia, Hassan Tower, Giralda
Marinids 1244–1465 Fes Fes el-Jdid and the great madrasas, including Bou Inania
Saadians 1549–1659 Marrakech Victory at the Battle of the Three Kings (1578); golden age of al-Mansur
Alaouites 1666–today Fes, Meknes, Rabat Current royal dynasty; independence restored in 1956

Watch the Story: Kings of Morocco

Reading this timeline is one thing; walking through it reign by reign is another. That is why we tell this same story, episode by episode and in chronological order, on our YouTube channel Kings of Morocco (kingsmorocco.com) — from the fossils of Jebel Irhoud and the Mauretanian kings, through the founding of Fes and the empires of Marrakech, to the Morocco of today. Each episode takes a single chapter of the history above and gives it the time it deserves. If this brief history left you wanting more, start with episode one and let the twelve centuries unfold in order. You can also read more about who we are and why we built this guide on our About page.

Frequently Asked Questions

How old is Morocco as a country?

The Moroccan state traces its founding to 788, when Idris I was proclaimed at Walili, making it one of the oldest continuously existing states in the world. Human settlement is far older: the Jebel Irhoud fossils date to around 300,000 years ago.

Who founded Fes, and why is it so important?

Idris II founded Fes in 808–809 as his capital. It became Morocco’s spiritual and intellectual heart, home to Al-Qarawiyyin (founded 859), and its medina, Fes el-Bali, is one of the largest and best-preserved medieval cities anywhere.

Is Al-Qarawiyyin really the world’s oldest university?

Al-Qarawiyyin was founded in 859 by Fatima al-Fihri as a mosque and school, and it has operated continuously ever since. UNESCO and Guinness World Records describe it as the oldest existing, continuously operating educational institution in the world, though it only gained formal university status in the modern era.

Was Morocco a French colony?

Not formally. From 1912 to 1956 Morocco was a protectorate: France (and Spain, in the north and south) administered the country, but the sultan remained head of state and Morocco was never annexed as a colony in law. Independence was restored in 1956 under Mohammed V.

Where does the name “Morocco” come from?

“Morocco” comes from “Marrakech,” filtered through Portuguese “Marrocos” — European traders named the whole country after its best-known imperial capital. In Arabic the country is al-Maghrib, “the land of the far west,” which is exactly where it sits: the western edge of the Arab and African worlds alike.

1 thought on “A Brief History of Morocco: From the Mauretanian Kings to Today”

Leave a Comment