Yusuf bin Tashfin founds Marrakesh

Prior to the advent of the Almoravids in the 11th century, the area was ruled from the city of Aghmat.

The Almoravid leader, Abu-Bakr Ibn-Umar decided Aghmat was becoming overcrowded and chose to build a new capital. He decided to build it in the plains near the Tansift river. He chose the site of Marrakech, because it was in neutral territory between two tribes who were vying for the honor of hosting the new capital.[citation needed] Work started in May 1070, but Abu-Bakr was recalled to the Sahara to put down a rebellion in January 1071 and the city was completed by his deputy and eventual successor Yusuf ibn Tashfin.