The sharifs of Hasanid descent, commonly referred to as the Banū Hasan, who ruled Mecca and its dependencies from the middle of the fourth century A.H./tenth century A.D. until the early twentieth century, can be divided into three major dynastic branches, each of which bears the name of the first of its members to attain the office of emir of Mecca. Thus, the first dynasty of the Hasanid sharifs of Mecca, known as the Jaʿfarids, was founded by Jaʿfar b. Muhammad b. al-Husayn al-Amīr, a descendant in the ninth generation of al-Hasan b. ʿAlī b. Abī Ṭālib, in about the year 357/968, shortly before the conquest of Egypt for the Fatimids of North Africa by their general, Jawhar, in 358/969. Control of Mecca remained in the hands of the Jaʿfarids until the last representative of the line, Shukr b. Abī'l-Futūḥ, died without leaving a male heir in 453/ 1061.