Chronicle of the Middle East and North Africa

History of Morocco

Fanack dives into the history of Morocco, going through the conclusive events that laid out this country’s present from a historian’s perspective.

History of Morocco
Sunlight on houses at Ksar Ait Ben Haddou, earthen fortified city, Ounila valley, Ouarzazate province, Morocco. The ksar is a group of earthen houses surrounded by high defensive walls with corner towers, in traditional pre-Saharan style. The village stands above the Oued Marghen river in the High Atlas and was a stop on the caravan route from the Sahara to Marrakech. It was founded in the 17th century and has been a UNESCO World Heritage Site since 1987. Picture by Manuel Cohen (Photo by Manuel Cohen / Manuel Cohen / Manuel Cohen via AFP)


A cliché says that Morocco is a mosaic where modernity and history intermingle. European-looking cities with apartment blocks, banks and offices sit alongside antique medinas, ancient mosques and mediaeval fortifications.

Outside city limits, rural Morocco depends on agriculture. Great estates watered by huge dams contrast with smaller landholdings dependent on weather. Beyond lies an even older Morocco of arid landscapes where settlement and agriculture rely on groundwater and oasis production. Desert regions are interspersed with the bulking presence of modern industry, extracting phosphates.

These urban and rural landscapes are filled with smaller manifestations of human presence: men and women dressed in western clothes move through the streets alongside Moroccan men wearing djellabas and women who cover their faces.

But the cliché can only go so far. It is the details of cities and landscapes that exemplify the unique features of Morocco: the street signs, advertising posters and graffiti, as well as media in Arabic, French and Amazigh (or Berber). Portraits of the king are not only in state offices and public buildings, but also in classy restaurants and inexpensive eateries and in private houses. The metaphor of mosaic is disrupted by layers of time.

In this history section, Fanack explores the roots of this complexity.


The desert frontiers of Morocco evolved in the third millennium BCE. The Romans conquered the northern part of what would become Morocco and founded the great city of Volubilis, surrounded by settled agriculture and linked to the trading economy of the Mediterranean basin. The Amazigh were the ancestors of the modern population of Morocco.

The coming of Islam

The cultural links with the Arab East were made clear when Arab invaders introduced Islam to Morocco in the early eighth century AD. Amazigh men joined the armies led by Tariq ibn Ziyad, the governor of Tangier, that invaded Spain from the south. Muslim rule spread, for a time, even into southern France. The new Moroccan city of Fez became a great centre of trade, industry and Islamic learning. It was the capital of the Idrisid state in the late 8th century. Some modern nationalists regard this as the first Moroccan state.

The Berber dynasties – the Almoravids, Almohads, and Banu Marin

Between the early eleventh century and the first part of the thirteenth century successive Amazigh dynasties ruled Morocco. The Almoravids and the Almohads both legitimized themselves with the ideology of a ‘pure Islam’.

The Almoravids originated in the Sahara and founded the great city of Marrakesh. They spread their rule partly towards what is now Algeria, but their anchor was in the Sahara, following the trail of gold. Their successors, the Almohads, moved eastwards through Algeria and Tunisia into what is now Libya.

Both empires sent troops to al-Andalus, the Islamic part of the Iberian Peninsula. They helped resist the Christian advance from the north and for a time controlled large areas of what is now Spain and Portugal.

In the mid-thirteenth century, Almohad power faltered and the Banu Marin (Marinids), formerly part of the Almohad army, took control of most of the territory that would become Morocco. The frontiers were fluid but they ran south through western Algeria to the Saharan trading centre of Sijilmasa. The Marinids failed to hold on to al-Andalus.

Morocco began to take shape in another way: Marinid fortified cities prospered and Fez became a rich centre of orthodox Islamic learning. The Marinids built madrasas in the cities to give Maliki scholars their education. Increasingly, Sufi sheikhs and Sharifian families ( descended from the Prophet Muhammad) dominated the countryside.

The Sharifian Dynasties – Saadis and Alawis

Popular veneration of Sharifian figures and Sufi brotherhoods (tariqas) provided leadership against Spanish and Portuguese invaders who occupied several enclaves along the coast. The Portuguese held Ceuta (1415) and Tangier (1471) at the mouth of the Mediterranean, and then moved southwards towards al-Jadida (then called Mazagan) in 1515. In 1497 the Spanish occupied their first Mediterranean outpost, Melilla. The Portuguese would lose all their outposts apart from Ceuta, which passed to Spain as one of a string of Spanish enclaves that has lasted until today. Tangier eventually ended up in British hands before becoming the diplomatic capital of Morocco and the site of an internationally controlled zone in the twentieth century.

The Saadis, the first of the two sharifian dynasties, effectively fixed the eastern boundary of Morocco roughly where it is today by holding back the Ottoman Empire. The Saadi Sultan Ahmad al-Mansur (reigned 1578-1603) pushed southwards into the Sahara. The large areas he controlled encouraged some twentieth-century nationalists to claim control of parts of Algeria, most of Mauritania and the territory that became Western Sahara, until today central to a dispute between Morocco and POLISARIO.

In 1603 the Saadi dynasty collapsed, following an outbreak of plague and a civil war between Ahmad al Mansur’s sons. That war lasted for half a century until another Sharifian family, the Alawis, seized control in the mid-seventeenth century.

The Alawis

Modern Morocco begins with the reign of the first effective Alawi sultan, Moulay Ismail (1672-1727). He imposed tight control over territory that at times included areas of the Sahara. Although there were subsequent periods of civil war, the dynasty never lost power and rules Morocco to this day. It is the oldest ruling family in the Muslim Middle East and North Africa.

European encroachment in the nineteenth century

From the mid-nineteenth century onwards European economic and political power grew. But the European powers were rivals among each other and competed over control of the far north-west of Africa.

Morocco was not an easy country to conquer: there was enormous resistance, particularly in the countryside, mountains and deserts. As a result, Morocco did not become a colony of a single European power, but the protectorate of two of them.

An international treaty, the Treaty of Fez of 1912, divided Morocco between France and Spain. The treaty also recognised continuing Spanish control of its enclaves on the coast and the barren colony of Spanish Sahara further south, which would become the contentious Western Sahara.

The Franco-Spanish Protectorates

The Treaty of Fez ruled that France and Spain would not own their colonies, but administer them as protectorates, preserving the Alawi dynasty and the sultan’s sovereignty. This sovereignty was fiction, but it preserved the dynasty as a symbol, both of the legitimacy of the protectorates and of Moroccan identity, around which a nationalist movement would evolve.

Both colonial powers imposed control over the mountains and deserts by force. The French did not achieve that until the early 1930s. For the Spanish it took an all-out war. Resistance came from the Rif mountains that inflicted the two largest defeats of colonial armies anywhere in the world in the twentieth century. A joint Spanish-French invasion brought the Rif resistance down in 1926.

The French Protectorate produced a settler colonial economy in the fertile parts of Morocco, and extensive development of communications and urban areas. But much of the population remained poor. Among the middle class, an urban nationalist movement massed around Sultan Mohammed V.

The Spanish zone was much less developed both economically and politically.


In the aftermath of the Second World War, when Morocco was invaded by US forces, the nationalist movement attached itself both to the monarchy that was ideologically aligned to Western Alliance and the wider Arab nationalist movement. After independence in 1956, the two parts of Morocco united and Mohammed V changed his title to King. He and his son Hassan II, who succeeded him in 1961, set up what was described as a constitutional monarchy, with various nationalist parties vying for power.

The palace did not allow free politics and heavily repressed opposition movements, especially during the 1970s and 1980s. During the reign of Hassan II(1961-1999), many Moroccan leftists and Islamists were arrested, held for long periods and tortured. Even so, democratic structures remained. Elections were held and although they were never free nor fair, they provided space for the king to incorporate various political actors to overcome opposition. He also won support by forcibly incorporating the former colony of Spanish Sahara, citing traditional links with its population.

The War in Western Sahara

In 1975 Morocco took control over the Western Sahara. It was not only an important nationalist symbol but also contained huge reserves of phosphates. At first, the Sahara was divided with Mauritania, but the Mauritanians soon gave up because of determined resistance by a local independence movement, POLISARIO. King Hassan was only able to impose control over the entire territory by having his army build a series of sand walls across the desert and cleansing the territory within them.

Preparations for regime change (1980-2000)

The economic problems caused by the expensive war over the Western Sahara and the world recession of the 1980s, made King Hassan realise that he had to provide his son, Mohammed, with a stable legacy. He opened the economy and the political system. In the late 1990s, he released political prisoners and encouraged capital investment.

A new monarchy

Mohammed succeeded his father as king in 1999. He continued reforming the economy and political life. Political reconciliation led to a national enquiry into the years of repression. In the end, the reconciliation was much more guarded than similar attempts in South Africa and South America. Few officials were held to account. The repression lessened but it did continue, particularly against Islamists.

Eventually, the palace reverted to King Hassan’s policy of incorporating potential opponents into the system. The principal Islamist party, the PJD, took part in elections and won many seats, but repression of more radical Islamist groups continued. To incorporate the growing Amazigh opposition, the constitution was changed to make their language, Tamazight, an official language and Amazigh culture was encouraged.

Morocco after the 'Arab Spring'

Despite large protests inspired by events in Libya, Tunisia and Egypt, the Moroccan regime successfully weathered the so-called ‘Arab Spring’ movements of 2011. In the decade that followed, the regime bought time in the Western Sahara War. In mainstream politics it allowed the Islamist PJD to take control of the government, after the party won a majority of seats in elections. Amazigh protests continued, particularly in the Rif, but the economy rebounded well. By the time of the COVID epidemic, the regime was strong enough to take decisive action to hold the disease in place.