The capital of the Almoravids and the Almohads played a decisive role in the development of medieval planning. Marrakesh (which gave its name to the Moroccan Empire) is the textbook example of a large Islamic capital in the Western world. With its maze of narrow streets, houses, souks (markets), traditional crafts and trade activities, and its medina, this ancient settlement is an outstanding example of a vibrant historic city.
Marrakesh was founded in 1071-72 by Youssef ben Tachfin on the site of the camp where Abou Bekr had left him in charge. From that point forward, Marrakesh was no longer an occasional stopping place for the Almoravids. It became the true capital of these conquering nomads who succeeded in stretching their empire from the Sahara to the Ebro and from the Atlantic to Kabylia.
The original layout of the medina dates back to the Almoravid period from which there still remain various monumental vestiges (ruins of the so-called Abou Bekr Kasbah, Youssef ben Tachfin Mosque and Ali ben Youssef Palace, not far from the Koutoubia, the pool and the 'Koubba' of Ali ben Youssef Mosque which were discovered in 1955, Bab Aylan gate, etc.). In essence it is an adaptation of the older urban model of Marrakesh.
The walls of the medina were built in 1126-27 following the order given by Ali ben Youssef. The planting of the palm groves, which at the present still cover a surface area of roughly 13,000 ha to the east of the city, has also been credited to the Almoravids. When in 1147 this dynasty bowed to the attacks of the Almohads led by Abdel Mou'men, the task of purification that was carried out did not spare the monuments which, for the most part, were destroyed by the victors. Nevertheless Marrakesh remained the capital. Under the Almohad rulers (1147-1269), Marrakesh experienced new and unprecedented prosperity.
Between 1147 and 1158, Abd el Mou'men had the Koutoubia Mosque built upon the ruins of the Almoravid foundations. Its incomparable minaret, key monument of Muslim architecture, is one of the major features of the cityscape and is the actual symbol of the city. The ruler's successors, Abou Yacoub Youssef and especially Yacoub el Mansour, were the ones who truly renovated the capital. They built new quarters, extended the city wall, fortified the Kasbah (1185-90) which was a prolongation of the city to the south with its own ramparts and gates (Bab Agnaou, Bab Robb), its mosque, palace, market, hospital, parade-ground and gardens. These leaders strengthened their control over their domains by planting crops (Menara to the west) and by civil engineering achievements, the best known of which are the Tensift Bridge and the kettara network in the palm groves.
The decline of Marrakesh, which began during the conquest of the city by the Merinids in 1269, never went beyond the point of no return, as is illustrated by a number of non-negligible constructions (Ben Salih Mosque and minaret, not long after 1321). The rebirth of the capital under the Saadian rulers (1510-1669) led to a new blossoming of the arts, as borne out by the ruins of the El Badi Palace and the Saadian tombs, whose precious architecture is isolated from the rest of the Kasbah by a wall. Some of the elements making up these refined and sumptuous constructions came from afar, such as the marble columns from Carrara which Montaigne observed being cut in Tuscany 'for the king of Morocco in Berberia'. Also dating back to the Saadian period is the restoration of the Ben Youssef Madrasa and the building of several fountains decorated with gypsum work and woodwork (Mouassine, Chrob ou Chouf and Bab Doukkala Fountains).
Under the reign of the Alawite dynasty, Marrakesh, the temporary capital, was graced with a new mosque, madrasas, palaces and residences harmoniously integrated into the homogeneous unit of the old town, which was surrounded by 10 km of clay and lime and beaten-cob ramparts. Beyond the walls were the great traditional areas of greenery: the palm groves, the Menara and, to the south, the Agdal gardens that were redesigned by Moulay Abd er Rahman (1822-59).