Marrakesh or Marrakech ( or ; Arabic: مراكش, romanized: murrākuš; Berber languages: ⵎⵕⵕⴰⴽⵛ, romanized: mṛṛakc) is the fourth largest city in the Kingdom of Morocco. It is one of the four Imperial cities of Morocco and is the capital of the Marrakesh-Safi region. The city is situated west of the foothills of the Atlas Mountains. Marrakesh is 580 km (360 mi) southwest of Tangier, 327 km (203 mi) southwest of the Moroccan capital of Rabat, 239 km (149 mi) south of Casablanca, and 246 km (153 mi) northeast of Agadir.
The region has been inhabited by Berber farmers since Neolithic times. The city was founded in 1070 by Emir Abu Bakr ibn Umar as the imperial capital of the Almoravid Empire. The Almoravids established the first major structures in the city and shaped its layout for centuries to come.