Idris II, born in 791, was the son and successor of Idris I. Idris I was a descendant of the Prophet Muhammad who fled from Abbasid-controlled territory after the Battle of Fakh because he had supported the defeated pro-Shi'a rebels. He used his prestige as a descendant of the Prophet to forge an alliance with local Berbers in 789 and quickly became the most important religious and political leader in the region. He died soon after in 791, just before his son Idris (II) was born.