The Mahdi (al-Mahdī) is a Final Leader in Islamic eschatology who is believed to appear at the end of times to rid the world of evil and injustice. He is said to be a descendant of Muhammad who will appear shortly before the Prophet ʿĪsā (Jesus Christ) and will lead the Muslims to rule the entire world.
Though the Mahdi is not referenced in the Quran, and is absent from several canonical compilations of hadith – including the two most-revered Sunni hadith collections: Sahih al-Bukhari and Sahih Muslim – he is mentioned in other hadith literature. Many Sunni theologians have therefore questioned the orthodoxy of the Mahdi. The doctrine of the mahdi seems to have gained traction during the confusion and unrest of the religious and political upheavals of the first and second centuries of Islam. Among the first references to the Mahdi appear in the late 7th century, when the revolutionary Mukhtar ibn Abi Ubayd (622 – 687) declared Muhammad ibn al-Hanafiyya, a son of caliph Ali (656-661), to be the Mahdi. Although the concept of a Mahdi is not an essential doctrine in Islam, it is popular among Muslims. It has been a part of the ʿaqīdah (creed) of Muslims for 1,400 years. Over centuries, there have been a vast number of Mahdi claimants.
The Mahdi features in both Shi'a and Sunni branches of Islam, though they differ extensively on his attributes and status. Among Twelver Shi'as, the Mahdi is believed to be Muhammad al-Mahdi, son of the eleventh Imam, Hasan al-Askari (874), who is said to be in occultation (ghayba) by divine will. This is rejected by most Sunnis, who assert that the Mahdi has not been born yet.
The term Mahdi is derived from the Arabic root h-d-y (ه-د-ي), commonly used to mean "divine guidance". Although the root appears in the Qur'an at multiple places and in various contexts, the word Mahdi never occurs in the book.
The associated verb is hada, which means to guide. However, Mahdi can be read in active voice, where it means the one who guides, as well as passive voice, where it means the one who is guided.