The Kasbah of Marrakesh is a large walled district in the southern part of the medina of Marrakesh, Morocco, which historically served as the citadel (kasbah) and royal palace complex of the city. A large part of the district is still occupied by the official royal palace, the Dar al-Makhzen, which serves as the residence of the King of Morocco when he visits the city. The rest of the district consists of various neighbourhoods and monuments. It was founded by the Almohads in the late 12th century, with most of the construction carried out by Caliph Ya'qub al-Mansur (r. 1184–1199). Two of its most important surviving structures today, the Kasbah Mosque and the main gate of Bab Agnaou, date from al-Mansur's reign.
The palace complex was neglected after the fall of the Almohads, but the Kasbah was restored and rebuilt by the Saadian dynasty in the 16th century, during the time of sultans Abdallah al-Ghalib and Ahmad al-Mansur, who created new palaces and extensive gardens. The Saadian Tombs and the ruins of the El Badi Palace date from this period. Abdallah al-Ghalib was also responsible for the creation of a Jewish quarter, the Mellah, adjoined to the Kasbah's eastern flank. Following another period of neglect and pillage, the palaces were rebuilt and redeveloped by the 'Alawi sultan Muhammad ibn Abdallah who gave the Royal Palace (Dar al-Makhzen) and its surroundings much of their present form.[1][2]
Today the kasbah is no longer a restricted district, apart from the royal palace, and is a popular tourist attraction in the city.