The Mahdi () is the Islamic messianic and eschatological figure, who is believed to appear before the End Times to restore justice and defeat tyranny alongside Isa (Jesus). He forms an important part of Islamic eschatology, although Sunni and Shia Muslims differ slightly in their interpretation of him. While the Mahdi is mostly developed in Shia Islam, he is also present in numerous Sunni hadiths. In Twelver Shia Islam, the Mahdi has a significant role. He is identified with the twelfth and final Imam Muhammad al-Mahdi, who was born in 869 AD, entered occultation, and remains alive until his eventual reappearance at the end times alongside Jesus. He is a descendant of Ali, the Islamic prophet Muhammad's cousin and son-in-law, and Fatima through their second son Husayn, Muhammad's grandson.
In Sunni Islam, the Mahdi is also described as a descendant of Muhammad through his daughter Fatima, who will emerge in the end times alongside Jesus. However, Sunni tradition does not identify him with a historical individual, nor do they attribute to him an occultation. The difference in Sunni Islam is that the Mahdi is a future figure who has not yet appeared, whereas in Shia Islam, he has already been born and is currently in occultation. The Mahdi has a central place in Islamic theology, devotional literature, and popular piety for over a millennium. He has influenced numerous religious, political, and messianic movements. Throughout history, there have been a vast number of Mahdi claimants. The signs of his reappearance are common in both Shia and Sunni branches. The belief in the Mahdi remains very popular among all Muslims, owing to numerous traditions in canonical Sunni and Shia hadith. It is popularly held that the Mahdi occasionally appears to pious individuals. Accounts of such encounters are numerous and widespread. Every year, millions celebrate Mid-Sha'ban, marking the birth of Muhammad al-Mahdi.
Etymology The term Mahdi is derived from the Arabic root h-d-y (), commonly used to mean "divine guidance". Although the root appears in the Quran 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.
Historical development Pre-Islamic ideas Mahdi's advent is linked to the Christian concept of the Second Coming of Jesus, the Jewish concept of Mashiach ben David, and the Zoroastrian concept of the Saoshyant. Some historians suggest that the term itself was probably introduced into Islam by southern Arabian tribes who had settled in Syria in the mid-7th century. They believed that the Mahdi would lead them back to their homeland and re-establish the Himyarite Kingdom. They also believed that he would eventually conquer Constantinople. It has also been suggested that the concept of the Mahdi may have been derived from earlier messianic Jewish and Christian beliefs. Accordingly, traditions were introduced to support certain political interests, especially anti-Abbasid sentiments. These traditions about the Mahdi appeared only at later times in hadith books such as and , but are absent from the early works of Muhammad al-Bukhari and Muslim ibn al-Hajjaj.
A historical hypothesis in comparative religion, championed by orientalists such as James Darmesteter and Ignaz Goldziher, suggests that the concept of The Mahdi—particularly in its eschatological and metaphysical dimensions—was structurally influenced by the ancient Zoroastrian savior myth of Saoshyant. Proponents of this hypothesis argue that because the Quran lacks explicit mention of the Mahdi and early Sunni Hadith literature provides limited metaphysical details, a theological vacuum was left in Islamic eschatology; this vacuum allegedly allowed Persian society, following the Muslim conquest of Persia, to project the mythological attributes of Saoshyant (such as pre-existence, occultation, and the cosmic renewal of the universe) onto general prophetic traditions regarding a reformer from Muhammad's lineage.
Conversely, Islamic scholars reject this influence hypothesis, asserting the prophetic authenticity of Mahdism based on mutawatir (successive) traditions, and interpret these structural similarities as a distorted "early divine prophecy" preserved in ancient faiths. Furthermore, historians note that this influence hypothesis weakens significantly when applied to the traditional Sunni view of the Mahdi, which conceptualizes him strictly as a human leader and historical reformer operating under natural laws, entirely stripped of the theosophical and metaphysical attributes assigned to the Zoroastrian savior.
In Islamic eschatology, particularly within Shīʿite traditions, various titles and names are attributed to the promised messianic figure, Imam al-Mahdi, to identify him as the universal savior prophesied in ancient civilizations. In his prominent work Al-Najm al-Thaqib (The Piercing Star), the Shīʿite scholar Mirza Husain Noori Tabarsi cites a treatise titled Dhakhirat al-Albab. According to this account, the Mahdi is mentioned across different ancient languages and scriptures. Specifically, the text records that in a book referred to as "Ista' " (interpreted by scholars as a corruption of the Zoroastrian holy text, the Avesta), the Mahdi is prophesied under the names "Bahram" (a Middle Persian term signifying the divinity of victory and the smiter of resistance) and "Bande Yazdan" (literally meaning "Servant of God" or Abdullah).
Origin The term al-Mahdi was employed from the beginning of Islam, but only as an honorific epithet ("the guide") and without any messianic significance. As an honorific, it was used in some instances to describe Muhammad (by Hassan ibn Thabit), Abraham, al-Husayn, and various Umayyad caliphs (, ). During the Second Muslim Civil War (680–692), after the death of Mu'awiya I (), the term acquired a new meaning of a ruler who would restore Islam to its perfect form and restore justice after oppression. Abd Allah ibn al-Zubayr, who laid claim to the caliphate against the Umayyads and found temporary success during the civil war, presented himself in this role. Although the title Mahdi was not applied to him, his career as the anti-caliph significantly influenced the future development of the concept. A hadith was promulgated in which Muhammad prophesies the coming of a just ruler. Refusing to recognize the new caliph, Yazid I (), after Mu'awiya's death in 680, Ibn al-Zubayr had fled to the Meccan sanctuary. From there he launched anti-Umayyad propaganda, calling for a of the Quraysh to elect a new caliph. Those opposed to the Umayyads were paying him homage and asking for the public proclamation of his caliphate, forcing Yazid to send an army to dislodge him in 683. After defeating rebels in the nearby Medina, the army besieged Mecca but was forced to withdraw as a result of Yazid's sudden death shortly afterward. Ibn al-Zubayr was recognized caliph in Arabia, Iraq, and parts of Syria, where Yazid's son and successor Mu'awiya II () held power in Damascus and adjoining areas. The hadith hoped to enlist support against an expected Umayyad campaign from Syria. The Umayyads did indeed send another army to Mecca in 692, but contrary to the hadith's prediction was successful in removing Ibn al-Zubayr. The hadith lost relevance soon afterward, but resurfaced in the Basran hadith circles a generation later, this time removed from its original context and understood as referring to a future restorer.
Around the time when Ibn al-Zubayr was trying to expand his dominion, the pro-Alid revolutionary al-Mukhtar al-Thaqafi took control of the Iraqi garrison town of Kufa in the name of Ali's son Muhammad ibn al-Hanafiyya, whom he proclaimed as the Mahdi in the messianic sense. The association of the name Muhammad with the Mahdi seems to have originated with Ibn al-Hanafiyya, who also shared the epithet Abu al-Qasim with Muhammad, the Islamic prophet. Among the Umayyads, the caliph Sulayman ibn Abd al-Malik () encouraged the belief that he was the Mahdi, and other Umayyad rulers, like Umar ibn Abd al-Aziz (), have been addressed as such in the panegyrics of Jarir () and al-Farazdaq ().
Early discussions about the identity of the Mahdi by religious scholars can be traced back to the time after the Second Fitna. These discussions developed in different directions and were influenced by traditions (hadith) attributed to Muhammad. In Umayyad times, scholars and traditionists not only differed on which caliph or rebel leader should be designated as Mahdi but also on whether the Mahdi is a messianic figure and if signs and predictions of his time had been satisfied. In Medina, among the conservative religious circles, the belief in Umar ibn Abd al-Aziz being the Mahdi was widespread. Said ibn al-Musayyib () is said to have identified Umar ibn Abd al-Aziz as the Mahdi long before his reign. The Basran, Abu Qilabah, supported the view that Umar ibn Abd al-Aziz was the Mahdi. Hasan al-Basri () opposed the concept of a Muslim Messiah but believed that if there was the Mahdi, it was Umar ibn Abd al-Aziz.
By the time of the Abbasid Revolution in 750, Mahdi was already a known concept. Evidence shows that the first Abbasid caliph al-Saffah () assumed the title of "the Mahdi" for himself.
Shia Islam In Shia Islam, the eschatological Mahdi was commonly given the epithet al-Qa'im (), which can be translated as 'he who will rise,' signifying his rise against tyranny in the end of time. Distinctively Shia is the notion of temporary absence or occultation of the Mahdi, whose life has been prolonged by divine will. An intimately related Shia notion is that of (), which often means the return to life of (some) Shia Imams, particularly Husayn ibn Ali, to exact their revenge on their oppressors.
Traditions that predicted the occultation and rise of a future imam were already in circulation for a century before the death of the eleventh Imam in 260 (874 CE), and possibly as early as the seventh-century CE. These traditions were appropriated by various Shia sects in different periods, including the now-extinct sects of Nawusites and Waqifites. For instance, these traditions were cited by the now-extinct Kaysanites, who denied the death of Ibn al-Hanafiyya, and held that he was in hiding in the Razwa mountains near Medina. This likely originated with two groups of his supporters, namely, southern Arabian settlers and local recent converts in Iraq, who seem to have spread the notions now known as occultation and . Later on, these traditions were also employed by the Waqifites to argue that Musa al-Kazim, the seventh Imam, had not died but was in occultation.
In parallel, traditions predicting the occultation of a future imam also persisted in the writings of the mainstream Shia, who later formed the Twelvers. Based on this material, the Twelver doctrine of occultation crystallized in the first half of the fourth (tenth) century, in the works of Ibrahim al-Qummi (), Ya'qub al-Kulayni (), and Ibn Babawayh (), among others. This period also saw a transition in Twelver arguments from a traditionist to a rationalist approach in order to vindicate the occultation of the twelfth Imam.
The Twelver authors also aim to establish that the description of Mahdi in Sunni sources applies to the twelfth Imam. Their efforts gained momentum in the seventh (thirteenth) century when some notable Sunni scholars endorsed the Shia view of the Mahdi, including the Shafi'i traditionist Muhammad ibn Yusuf al-Gandji. Since then, Amir-Moezzi writes, there is Sunni support from time to time for the Twelvers' view of Mahdi. There has also been some support for the mahdiship of the twelfth Imam in Sufi circles, for instance, by the Egyptian Sufi al-Sha'rani.