Youssef Ben Tachfin, sultan of Almoravides, founded Marrakech in 1062. At that time, the city became one of the principal arts centres of the Islamic world.
In 1147, the principal buildings of the city were shaved by Almohades to be rebuilt shortly after by Andalusian craftsmen.
Marrakech remained capital Almohade empire until 1269, date on which Mérinides established their capital with Fès.
In XVIè century, Marrakech became again the capital of the country, joining again with prosperity under the reign saadien of which one of the most famous sultans was Ahmed El Mansour who in particular made build the Palate el Badi as well as the necropolis royal ("Tombs saadiens"). Alaouites, successors of Saadiens, chose Meknès like capital.
To the XIXè century, only Moulay el Hassan Ier gave to Marrakech a little prestige. At the XXè century, the new city was built by the French authorities and repopulated Médina.