Answer
The Idrisid dynasty was founded in 788 by Idris I, a descendant of Muhammad through his grandson Hasan. Idris I had been exiled from Mecca and Medina by the Abbasid caliph Harun al-Rashid, and he established his capital at Volubilis, a Roman city in what is now Morocco. The Idrisid dynasty ruled Morocco until the 10th century, when it was overthrown by the Almoravids.