Marrakech is one of the Imperial Cities founded in 1062 by The Almoravide Sultan Youssef ben Tachfine who is credited with construction of the defensive walls that encircle the city. Extended to 19 kms during the dynasties of the Almohades and Saadiens, the spectacular city walls, varying in colour between pink and red. The prosperity of Marrakech at this time made it a fitting capital for an empire which stretched from Algiers to the Atlantic and from the Mediterranean almost to Senegal.
The rule of Yousef Ben Tachfine blessed Marrakech with its legendary walls, several mosques, fine gardens and palaces. The Almoravid conquest of southern Spain led to an exchange of culture investing this remote desert enclave with the cosmopolitan atmosphere of Andalucia, something that it has retained a feel for to this day.
The architectural influence of the Almohads was strong and featured carved domes and arches. When blended with influences from the Sahara and West Africa, it created a unique style of architecture in the city. Many of the city's best-known landmarks, such as the the Koutoubia and El Mansour Mosques, date from their conquest. The vast walls that encase the medina were built in the 12th century out of red sandstone, earning the city the name ‘Red City’ or ‘Ochre City’. Marrakech’s rapid growth turned it into a cultural, religious and trading centre and despite a later period of decline, it resurged in the 16th century during the reign of wealthy Saadian sultans, who built magnificent palaces such as El Badi Palace.
In 1912 the Treaty of Fes recognised Morocco as a French Protectorate under the notional sovereignty of the sultan. During the next 40 years the country made significant economic progress thanks to development by the French of rail and road infrastructure and the introduction of hydro-electrical installations, irrigation systems and national education. The modern commercial and residential quarter of Gueliz, outside the Marrakech medina, was completed shortly before Morocco became a fully independent country once more in 1956.