For a long time, Marrakesh was a major political, economic and cultural center of the Muslim world, under the aegis of the various succeeding dynasties.
The city was founded in 1070 by Youssef Ibn Tachfin, first king of the Almoravid dynasty. In less than half a century, Marrakesh became the capital of a vast empire stretching from Andalusia to the borders of Sudan. A great number of mosques and Koranic schools were built and ramparts erected to protect the city.
The Almohads then took over the city and built palaces and religious buildings such as the famous Koutoubia Mosque. At the end of the 13th century, Marrakesh was conquered by the Merinid nomads and lost its initial role as a center of power and knowledge to the city of Fez, which became the capital.
At the beginning of the 16th century, Marrakesh regained a central place by becoming the capital of the kingdom. The arrival of the Saadians was the symbol of the rebirth of the city. Among other major buildings, Sultan Ahmed El-Mansour had the El-Badii Palace built as a replica of the Alhambra of Andalusia, as well as the Saadian tombs.
At the end of the Saâdian dynasty, Marrakesh sank into oblivion and much of its prestige and heritage fell into ruin. It was not until the reign of the Alaouites that the city regained its prestige with the restoration of the city walls, the Kasbah and the construction of new buildings and mosques. At the beginning of the 20th century, Marrakesh was ruled by the Pasha Thami El Glaoui until the end of the protectorate. In 1956, the end of the protectorate and the return from exile of Mohamed V marked the end of the reign of El Glaoui.