Marrakesh, or Marrakech (Berber: ⵎⵕⵕⴰⴽⵛ; Arabic: مراكش, Murrākuš) was a major city in the northwest African nation of Morocco. It was the fourth largest city in the country after Casablanca, Fes and Rabat, and is the capital of the mid-southwestern economic region of Marrakesh-Tensift-El Haouz. Located to the north of the foothills of the snow-capped Atlas Mountains, by road Marrakesh is located 580 km (360 mi) southwest of Tangier, 327 km (203 mi) southwest of the Moroccan capital of Rabat, 239 km (149 mi) southwest of Casablanca, and 246 km (153 mi) northeast of Agadir.
Marrakesh is the most important of Morocco's four former imperial cities. Inhabited by Berber farmers from Neolithic times, the city was founded in 1062 by Abu Bakr ibn Umar, chieftain and cousin of Almoravid king Yusuf ibn Tashfin. In the 12th century, the Almoravids built many madrasas (Koranic schools) and mosques in Marrakesh that bear Andalusian influences. The red walls of the city, built by Ali ibn Yusuf in 1122-1123, and various buildings constructed in red sandstone during this period, have given the city the nickname of the "Red City" or "Ochre City". Marrakesh grew rapidly and established itself as a cultural, religious, and trading centre for the Maghreb and sub-Saharan Africa; Jemaa el-Fnaa is the busiest square in Africa. After a period of decline, the city was surpassed by Fes, but in the early 16th century, Marrakesh again became the capital of the kingdom. The city regained its preeminence under wealthy Saadian sultans Abu Abdallah al-Qaim and Ahmad al-Mansur, who embellished the city with sumptuous palaces such as the El Badi Palace (1578) and restored many ruined monuments. Beginning in the 17th century, the city became popular among Sufi pilgrims for Morocco's seven patron saints, who are entombed here. In 1912 the French Protectorate in Morocco was established and T'hami El Glaoui became Pasha of Marrakesh and held this position nearly throughout the duration of the protectorate until the role was dissolved upon independence of Morocco and the reestablishment of the monarchy in 1956. In 2009, Marrakesh mayor Fatima Zahra Mansouri became the second woman to be elected mayor in Morocco.