Rabat is located on the south bank of the Wadi Bu Regreg, which separates Rabat from the city of Salé. Originally a Punic, then Roman settlement, Rabat's name alludes to the Ribat al-Fath, a fortress founded in 1150 by the Almohad ruler 'Abd al-Mu'min. During his reign the initially military encampment developed into a small town, known as al-Mahdiya, with a mosque and royal residence.
Later in the twelfth-century the Almohad ruler Abu Yusuf Ya'kub al-Mansur provided Rabat with its walls, punctuated by two monumental gates. The trapezoidal walled city, or medina, to which al-Mansur added the qasba and to which the Jewish quarter or mellah was added later, forms the core of Rabat. Al-Mansur was also the patron of the monumental mosque which was never completed, and of which only the minaret remains.
Conquered by the Marinid dynasty in 1248, Rabat's new rulers constructed the royal necropolis of Chella beyond the Almohad walls, on the site of the former Roman town. However, Rabat remained of secondary importance to Salé across the river until an influx of immigrants from Spain changed the balance of economic power in the seventeenth-century. Piracy was a major source of revenue for Rabat during this period, reflected in the re-orientation of the town toward the sea through the construction of a new port and fortifications.
The 'Alawi dynasty, which ruled the city into the twentieth-century, conquered Rabat in the second half of the seventeenth-century. Their rulers endowed the city with new mosques, palaces and a city wall extending to the south and west of the Almohad territory.
Sources:
Abu-Lughod, J. L. Rabat: Urban Apartheid in Morocco. Princeton: Princeton UP, 1980.
Dhahabial, Nufisah. Ribatat wa-al-zawaya fi tarikh al-Maghrib : dirasat tarikhiyah muhdah lil-Ustadh Ibrahim Harakat. al-Rabat : al-Mamlakah al-Maghribiyah, 1997.