Marrakech was founded around 1070 by Abu Bakr ibn Umar, a leader of the Almoravids — a reformist Berber movement out of the western Sahara — as a garrison camp beside a natural oasis at the foot of the Atlas Mountains; his cousin and successor Yusuf ibn Tashfin developed it into the dynasty’s capital, drawing on the wealth of trans-Saharan trade routes that carried gold, salt and slaves between West Africa and the Mediterranean. The Almoravids fell in 1147 to the Almohads, a rival Berber reform movement who besieged and captured Marrakech, and — finding the existing Almoravid mosque misaligned with Mecca — demolished it and built the Koutoubia Mosque in its place, its minaret still the city’s defining silhouette and the model for Seville’s Giralda and Rabat’s Hassan Tower under the same dynasty’s later rule. Under the Almohads, Marrakech briefly commanded an empire stretching from Spain and Portugal to present-day Libya, before the dynasty’s own decline in the 13th century shifted the region’s capital northward to Fez for long stretches of the following centuries.
The Saadian dynasty restored Marrakech as capital in the 16th century, its sugar and trans-Saharan trade wealth funding the Saadian Tombs and El Badi Palace, before the Alaouite dynasty that still reigns in Morocco today took power in the 17th century and, under Sultan Moulay Ismail, stripped El Badi Palace for building material and largely favoured Meknes and Fez, leaving Marrakech to a long decline until the Alaouites revived it once more in the 19th and early 20th centuries, adding the Bahia Palace for a powerful vizier in the 1860s-1880s. France established a protectorate over Morocco in 1912, and Resident-General Hubert Lyautey’s planning policy — preserving the old medina rather than redeveloping it, while building an entirely new administrative and residential quarter, Gueliz, alongside it — left Marrakech with the twin old-and-new-city structure still visible today; Morocco regained independence in 1956, and the medina’s red-ochre walls, built from the local clay that gives the city its French nickname “la ville rouge”, were inscribed as a UNESCO World Heritage site in 1985, the same walls now overlooking a city whose name — from the Amazigh for “Land of God” — was carried by Portuguese and Spanish traders into the country’s own name in most of the world’s languages.