Rabat's history began with a settlement, known as Chellah on the banks of the Oued Bou Regreg[4] in the third century BC. In 40 AD, Romans took over Chellah and converted it to the Roman settlement of Sala Colonia. Rome held the colony until 250 AD when they abandoned it to local rulers. In 1146, the Almohad ruler Abd al-Mu'min turned Rabat's ribat into a full scale fortress to use as a launching point for attacks on Spain. In 1170, due to its military importance, Rabat acquired the title Ribatu l-Fath, meaning "stronghold of victory," from which it derives its current name.
Yaqub al-Mansur (known as Moulay Yacoub in Morocco), another Almohad Caliph, moved the capital of his empire to Rabat. He built Rabat's city walls, the Kasbah of the Udayas and began construction on what would have been the world's largest mosque. However, Yaqub died and construction stopped. The ruins of the unfinished mosque, along with the Hassan Tower, still stand today.
Yaqub's death initiated a period of decline. The Almohad empire lost control of its possessions in Spain and much of its African territory, eventually leading to its total collapse. In the 13th century, much of Rabat's economic power shifted to Fez. In 1515 a Moorish explorer, El Wassan, reported that Rabat had declined so much that only 100 inhabited houses remained. An influx of Moriscos, who had been expelled from Spain, in the early 17th century helped boost Rabat's growth.