It was founded in 833 by the Idrisid dynasty, under the reign of the Emir Muhammad ibn Idris II. It was originally the summer capital of the Idrisid dynasty from the 8th to 10th centuries after they were driven out of Fes by the Fatimids.
Founded in 833 under the reign of Emir Muhammad ibn Idris II, the dynasty was initially the summer capital of the Idrisid kingdom from the 8th to the 10th centuries. The Idrisids were forced out of Fes by the Fatimids.