The fertile plains inland from Rabat drew settlers to the area as far back as the 8th century BC. Both the Phoenicians and the Romans set up trading posts in the estuary of the Bou Regreg river in Sala, today’s Chellah. The Roman settlement, Sala Colonia, lasted long after the empire’s fall and eventually became the seat of an independent Berber kingdom. The Zenata Berbers built a ribat, a fortress-monastery from which the city takes its name, on the site of Rabat’s present kasbah. As the new town of Salé (created in the 10th century) began to prosper on the north bank of the river, the city of Chellah fell into decline.
The arrival of the Almohads in the 12th century saw the ribat rebuilt as a kasbah, a strategic jumping-off point for campaigns in Spain, where the dynasty successfully brought Andalusia back under Muslim rule. Under Yacoub Al Mansour (the Victorious), Rabat enjoyed a brief heyday as an imperial capital, Ribat Al Fatah (Victory Fortress). Al Mansour had extensive walls built, added the enormous Bab Oudaia to the kasbah and began work on the Hassan Mosque, intended to be the greatest mosque in all of the Islamic West, if not in all of the Islamic world.
Al Mansour’s death in 1199 brought an end to these grandiose schemes, leaving the great Hassan Mosque incomplete. The city soon lost all significance, and it wasn’t until the 17th century that Rabat’s fortunes began to change.
As Muslim refugees arrived from Christian Spain, so did a band of Christian renegades, Moorish pirates, freebooters and multinational adventurers. Rabat and Salé became safe havens for corsairs – merciless pirates whom English chroniclers called the Sallee Rovers. At one point, they even created their own pirate state, the Republic of Bou Regreg. These corsairs roved as far as the coast of North America seeking Spanish gold, and to Cornwall in southern England to capture Christian slave labour. The first Alawite sultans attempted to curtail their looting sprees, but no sultan ever really exercised control over them. Corsairs continued attacking European shipping until well into the 19th century.
Meanwhile, Sultan Mohammed Ben Abdallah briefly made Rabat his capital at the end of the 18th century, but the city soon fell back into obscurity. In 1912, France strategically abandoned the hornet’s nest of political intrigue and unrest in the traditional capitals of Fez and Marrakesh and instead shifted power to coastal Rabat, where supply and defence were more easily achieved. Since then, the city has remained the seat of government and official home of the king.