Muḥammad ibn al-Ḥanafiyya (, 15–81 AH, CE 637–700) was a son of Ali ibn Abi Talib, who was the fourth Rashidun caliph () and the first Shia imam. Ibn al-Hanafiyya was an effective lieutenant for his father Ali during his caliphate. After the assassination of Ali and the deaths of his two sons Hasan and Husayn, many recognized Ibn al-Hanafiyya as the head of the House of Ali. Claiming to represent Ibn al-Hanafiyya, Mukhtar al-Thaqafi rose in Iraq in 686 to avenge Husayn and his relatives, who were massacred in 680 CE by the Umayyad caliph Yazid bin Mu'awiya (). The quiescent Ibn al-Hanafiyya did not actively associate with this rebellion but was still rescued by Mukhtar when he was detained by the rival caliph Ubayd Allah ibn Ziyad. Support for Ibn al-Hanafiyya continued even after the defeat and death of Mukhtar in 686687 in the form of the Kaysanites, a now-extinct Shia sect that traced the imamate to Ibn al-Hanafiyya and his descendants, particularly his son Abu Hashim. After the death of Ibn Hanafiyya in 700701, some Kaysanites declared that he was the Mahdi, the eschatological Islamic leader who would reappear in the end of time and eradicate injustice and evil. The Kaysanites later provided the organizational structure for the Abbasids to overthrew the Umayyads in 750751.

Birth

Often known by his title Ibn al-Hanafiyya, Muhammad was born to Khawla bint Ja'far, a woman from the Banu Hanifa tribe, and Ali ibn Abi Talib, a cousin of the Islamic prophet Muhammad. Ali is also recognized as the fourth Rashidun caliph () and the first Shia imam. Ibn al-Hanafiyya was either born in 16 AH (637638 CE), or circa 633. He was the only child of Khawla, a freed slave, whom Ali had married sometime after the death of his first wife Fatima, daughter of Muhammad. The of Ibn Hanafiyya was Abu al-Qasim.

Muhammad ibn al-Hanafiyya

Early life

Soon after the assassination of the third Rashidun caliph Uthman ibn Affan (), Ali was elected to the caliphate in Medina. During his caliphate, Ibn al-Hanafiyya accompanied Ali in battles, as his champion and standard-bearer. When Ali was assassinated in Kufa in January 661, his eldest son Hasan was elected caliph there, but later abdicated in favor of Mu'awiya () in August 661. Hasan was poisoned and killed in 669 in Medina, most likely at the instigation of Mu'awiya, who thus paved the way for the succession of his son Yazid (), often portrayed by Muslim historians as impious and immoral. Hasan was thus succeeded by his younger brother Husayn as the head of Muhammad's family. When the Umayyad Marwan and the prophet's widow Aisha prevented the burial of Hasan near his grandfather, Ibn Hanafiyya is said to have convinced Husayn to bury their brother in the Baqi Cemetery.

Muhammad ibn al-Hanafiyya

Battle of Karbala

Upon Mu'awiya's death and Yazid's accession in 680, the latter instructed his governor of Medina to secure Husayn's pledge of allegiance by force. Husayn immediately left for Mecca to avoid recognizing Yazid as the caliph. There Husayn received some letters of support from Kufans, whose intentions were verified by his envoy, Muslim ibn Aqil. Among many others, Ibn al-Hanafiyya is said to have warned Husayn not to trust the Kufans, who had betrayed their father Ali and their brother Hasan, suggesting that he should instead stay in Mecca or conceal himself in Yemen. Husayn ignored such warnings, saying that he expected to be killed while fighting the tyranny of Yazid. On their way to Kufa in 680, Husayn's small caravan was intercepted by the Umayyad army. He was killed in the ensuing Battle of Karbala, alongside most of his male relatives and his small retinue, having been surrounded for some days and deprived of the drinking water of the nearby Euphrates River. After the battle, the women and children in Husayn's camp were taken prisoner and marched to the Umayyad capital Damascus in Syria. The promised Kufan support did not materialize as Ubayd Allah ibn Ziyad, the new governor of Kufa, killed Husayn's envoy and intimidated Kufan tribal chiefs. Unlike Husayn, the quiescent Ibn al-Hanafiyya is said to have pledged his allegiance to Yazid.

Muhammad ibn al-Hanafiyya