<P> 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 . </P> <P> Rabat and neighboring Salé united to form the Republic of Bou Regreg in 1627 . The republic was run by Barbary pirates who used the two cities as base ports for launching attacks on shipping . The pirates did not have to contend with any central authority until the Alaouite Dynasty united Morocco in 1666 . The latter attempted to establish control over the pirates, but failed . European and Muslim authorities continued to attempt to control the pirates over many years, but the Republic of Bou Regreg did not collapse until 1818 . Even after the republic's collapse, pirates continued to use the port of Rabat, which led to the shelling of the city by Austria in 1829 after an Austrian ship had been lost to a pirate attack . </P> <P> The French invaded Morocco in 1912 and established a protectorate . The French administrator of Morocco, General Hubert Lyautey, decided to relocate the country's capital from Fez to Rabat . Among other factors, rebellious citizens had made Fez an unstable place . Sultan Moulay Youssef followed the decision of the French and moved his residence to Rabat . In 1913, Gen. Lyautey hired Henri Prost who designed the Ville Nouvelle (Rabat's modern quarter) as an administrative sector . When Morocco achieved independence in 1955, Mohammed V, the then King of Morocco, chose to have the capital remain at Rabat . </P> <Table> <Tr> <Td> </Td> <Td> This section does not cite any sources . Please help improve this section by adding citations to reliable sources . Unsourced material may be challenged and removed . (October 2012) (Learn how and when to remove this template message) </Td> </Tr> </Table>

When did rabat become the capital of morocco