The ochre city

Marrakech “in Arabic: Mourrakouch” was founded in the year 1071 (year 463 of the Hegira) by the Almoravid sovereign Youssef Ibn Tachfin. The name of Marrakech comes from the Tamazight Mour which means "country" and Akouch which means "God", which gives "the land of God". Another etymology gives the interpretation of "land of course". ) were built, as well as a commercial center draining traffic between the Western Maghreb and sub-Saharan Africa. Marrakech grew rapidly and established itself as an influential cultural and religious metropolis, supplanting Aghmat and Sijilmassa

Palaces were also built and decorated with the help of Andalusian craftsmen from Cordoba and Seville, who brought the Umayyad style characterized by chiseled domes and poly-lobed arches. This Andalusian influence merged with Saharan and even West African elements and was synthesized into an original architecture totally adapted to the specific environment of Marrakech. The city became the capital of the Almoravid Emirate which extended from the shores of Senegal to the center of Spain and from the Atlantic coast to Algiers.
The city was then fortified by the son of Youssef Ibn Tachfin, Ali Ben Youssef, who had the ramparts built around 1122-1123, which are still visible.
In 1147 the Almohads, supporters of an orthodox Islam and from the Masmoudas tribes of the High Atlas, took over the city. The last Almoravids were exterminated except for those who went into exile in the Balearic Islands (Beni Ghania family). As a result, almost all the monuments were destroyed. The Almohads built many palaces and religious buildings, such as the famous Koutoubia mosque built on the ruins of an Almoravid palace, and twin sister of the Giralda in Seville and the Hassan Tower (unfinished) in Rabat.
The Kasbah housed the caliphal residence (since the reign of Abd al-Mu'min the Almohad ruler bore the title of caliph, thus competing with the distant eastern caliphate of the Abbasids), embellished with a hospital that attracted the Andalusian physician Ibn Toufayl. Of the majestic complex of the Mansourian Kasbah, named after the Caliph Abu Yousef Yaqoub al-Mansour, the superb gate of Bab Agnaw still remains. Marrakech was thus worthy of housing the capital of the major power of the Mediterranean Muslim West at the time, the Almohad Empire which encompassed the entire region between Cordoba and Tripoli, from Spain to Libya.At the end of the seventeenth century, the Alawite dynasty succeeded the Saadians. The throne was successively transferred to Fez and then to Meknes, the new imperial city. Sultan Mohammed III (1757-1790) chose the city as his main residence because of its proximity to the port of Mogador (now Essaouira), which he had built according to the plans of the French architect Théodore Cornut. It was also in Marrakech that the first treaty of friendship between Morocco and the newly independent United States was signed in 1787. In 1792, Marrakech became the capital of a son of Mohammed III, Hicham, who was recognized as sultan by this part of the country while his brother Sulayman was recognized as the legitimate sultan in Fez by the ulama and by the provinces north of the Oum Errabiaa River. There followed a war between the two rival sultans, which ended with the defeat of Hicham in 1796, despite the Spanish support he enjoyed. Marrakech was reconquered by Sulayman in 1797 and the city returned to the territory of the official makhzen of Fez.

At the beginning of the 20th century, Marrakech experienced several years of unrest. After the death of the Grand Vizier Ba Ahmed in 1900, who was the real regent of the Cherifian Empire during the minority of the young Sultan Abd al-Aziz, the country was plagued by anarchy, tribal revolts, and plots by the great feudal lords, not to mention European intrigues. In 1907, Moulay Abd al-Hafid, khalifa (representative of the makhzen) in Marrakech was proclaimed sultan by the powerful tribes of the High Atlas and by certain ulama who denied the legitimacy of his brother Abd al-Aziz. It was also in 1907 that a French doctor living in Marrakech, Dr. Mauchamp, was murdered on suspicion of spying for his country. France seized this case to bring its troops into Morocco, from Oujda in the east and Casablanca in the west.
However, the French colonial army encountered strong resistance led by Ahmed al-Hiba, a son of the great sheikh Ma El Aïnin, who came up from the Sahara with his nomadic warriors from the Reguibat tribes. After the battle of Sidi Bou Othmane, which saw the victory of the Mangin column over al-Hiba's forces (September 1912), the French seized Marrakech, which thus became part of the French protectorate of Morocco established in March 1912. 

The conquest was facilitated by the rallying of the Imzwarn tribes and their chiefs belonging to the powerful Glaouis family.
One of them, Thami El Glaoui, became famous when he became pasha of Marrakech, a position he held for practically the entire duration of the protectorate (44 years). The pasha Glaoui became famous for his collaboration with the authorities of the general residence, which culminated in the plot to dethrone Mohammed Ben Youssef (Mohammed V) and replace him with the sultan's cousin, Ben Arafa.
Thami El Glaoui, already renowned for his prestigious company and his lavish lifestyle, worthy of a true monarch, thus became a prominent symbol of the colonial and colonialist order in Morocco. Nevertheless, he could not oppose the rise of nationalist sentiment, nor the hostility of a growing part of the population. He could not oppose either the pressures of France, which agreed to get rid of its Moroccan protectorate because of the disaster of the Indochina war and the beginning of the Algerian war. After two successive exiles (in Corsica and Madagascar), Mohammed Ben Youssef was allowed to return to Morocco (November 1955), and this return marked the end of the Glaoui's despotic reign over Marrakech and its region.