A Hasanid Alid uprising in Mecca is crushed by the Abbasids at the Battle of Fakhkh. Idris ibn Abdallah flees to the Maghreb, where he later founds the Idrisid dynasty.
The Battle of Fakhkh (Arabic: , romanized: yawm Fakhkh, lit.'Day of Fakhkh') was fought on 11 June 786 between the forces of the Abbasid Caliphate and the supporters of a pro-Alid rebellion in Mecca under al-Husayn ibn Ali, a descendant of Hasan ibn Ali.
Husayn and his supporters planned an uprising at Medina during the annual Hajj pilgrimage of 786, but their hand was forced by a confrontation with the local governor, al-Umari. The conspirators rose in revolt on the morning of 16 May, and seized the Mosque of the Prophet, where Husayn's supporters swore allegiance to him. The revolt failed to gather support among the populace, and the reaction of the Abbasid garrison prevented the rebels from establishing control over the city, and eventually confined them to the Mosque itself. After eleven days, the Alids and their supporters, some 300 strong, abandoned Medina and headed to Mecca.
Informed of these events, the Abbasid caliph al-Hadi appointed his uncle Muhammad ibn Sulayman ibn Ali to deal with the rebels, with an army composed chiefly of the armed retinues of the various Abbasid princes who on that year had gone to the pilgrimage. In the ensuing battle, at the wadi of Fakhkh near Mecca, Husayn and over a hundred of his followers were killed, many others were captured, and some escaped by passing themselves off as pilgrims, including the future founder of the Idrisid dynasty in what is now Morocco. The uprising had a strong social character, with Husayn drawing inspiration from Zayd ibn Ali's 740 revolt, and itself impacted later Zaydi Shi'a practices.
The Hasanids (Arabic: بنو حسن, romanized: Banū Ḥasan or حسنيون, Ḥasanīyyūn) are the descendants of Hasan ibn Ali, a grandson of the Islamic prophet Muhammad.
They are a branch of the Alids (the descendants of Ali ibn Abi Talib), and one of the two most important branches of the ashrāf (the other being the descendants of Hasan's brother Husayn, the Husaynids).In Morocco, the term is particularly applied to the descendants of Muhammad al-Nafs al-Zakiyya, to distinguish them from the Idrisid dynasty, which is also of Hasanid descent. The Moroccan Hasanids proper have produced two dynasties, the Saadi dynasty and the Alaouite dynasty, which still reigns over the country.