Rabat was founded in the 12th century by the Almohad ruler Abd al-Mu'min as a military town. The city steadily grew but went into an extended period of decline following the collapse of the Almohads. In the 17th century Rabat became a haven for Barbary pirates. The French established a protectorate over Morocco in 1912 and made Rabat its administrative center. Morocco achieved independence in 1955 and Rabat became its capital.