The Hasanids (Arabic: بنو حسن|Banū Ḥasan or Arabic: حسنيون,) are the descendants of Hasan ibn Ali, brother of Husayn ibn Ali and grandson of 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 (the other being the descendants of Hasan's brother Husayn, the Husaynids).
Unlike the Husaynids, who accommodated themselves with the Abbasids, the Hasanids insisted on challenging the Abbasids' right to lead the Muslim world, launching unsuccessful revolts in 762 and 786. after the suppression of the latter, a Hasanid branch, the Idrisids, settled in northern Morocco.
In Morocco, the term is particularly applied to the descendants of Muhammad al-Nafs al-Zakiyya, to distinguish them from the Idrisids. The Moroccan Hasanids proper have produced two dynasties, the Saadi dynasty and the Alawite dynasty, which still reign over the country.
Notable Ḥasanid dynasties in the Muslim world include: