All Muslims agree that at the end of time al-Mahdi will reappear to make justice prevail on earth after being overwhelmed with injustice, corruption, and tyranny. However, the dispute between the different schools of thought is as to who he is, and whether or not he is already born. Great scholars emphasize that al-Mahdi is a member of the Ahlul Bayt (the Family of the Prophet):
Imam al-Bukhari narrates from the Prophet Muhammad, “How will you feel once the son of Mary descends among you, and your leader (imam) is from you?”
Imam Muslim narrates from the Prophet Muhammad, “A caliph will be appearing at the end of time from my nation.” Timridhi and Abu Dawud, commenting on this hadith, say that this caliph will be al-Mahdi.
Abu Dawud narrates from the Noble Prophet, “If there remained but a single day until the end of time, Allah will prolong that day until He sends a man from my progeny whose name will be like mine and who fill the earth with justice and equity as it had been filled with oppression and tyranny.” 
Ibn Majah narrates from the Prophet Muhammad, “We are the Ahlul Bayt for whom Allah has chosen the hereafter to this world. My Ahlul Bayt after me will face difficulties, hardships, and persecution in the land until a group of people will come from the East, bearers of black banners. They will demand the right, but it will be denied. So they will fight and emerge victorious. They will be given what they demanded but will not accept it until they give the right to rule to a man from my Ahlul Bayt, who will fill the earth with justice as it was filled with oppression.”
Ibn Majah also narrates from the Prophet Muhammad, “The Mahdi is from us, the Ahlul Bayt. He is among the children of Fatima.”
Tirmidhi narrates from the Prophet Muhammad, “A man from my Ahlul Bayt whose name is like mine will verily rule the world and if there remains but a single day before the end of time, Allah will prolong that day until he assumes rule.”
According to the Shi‘a school of thought, Imam Muhammad ibn al-Hassan al-Mahdi was born in 255H (869AD) on the 15th of the month of Sha’ban in the city of Samarra in northern Iraq. His father was Imam Hassan al-Askari, whose lineage traces back to Imam ‘Ali ibn Abi Talib, and his mother’s name was Narjiss.
He is the last of the twelve imams for the people on earth, and with him the line of succession to the Prophet ends. Due to the necessity of having a representative from Allah present on earth, he is still, by the will of Allah, living in this world—but out of the public view. He will however reappear towards the end of human civilization to restore order and justice at a time when the world will be filled with evil and injustice.
Although the idea of Imam al-Mahdi still being alive after nearly thirteen centuries is difficult for some people to fathom, nonetheless, the Noble Qur’an sets several examples of prophets who lived even longer than al-Mahdi has lived, such as Prophet Isa, and al-Khidr (see Qur’an, chapter 18, verses 60-82 for his story with Prophet Musa). The Noble Qur’an also gives two other examples about people who died and then were resurrected by Allah. One is the example of the companions of the Cave (ashab al-kahf; see Qur’an, chapter 18, verse 25). The other is the example of ‘Uzayr:
Or like the one who passed by the town, and it had tumbled over its roofs. He said, ‘How will Allah ever bring it alive after its death?’ So Allah caused him to die for a hundred years and raised him up again. He said, ‘How long did you remain dead?’ He replied, ‘Perhaps I remained dead a day, or part of a day.’ He said, ‘Nay! You have remained dead for a hundred years. Look at your food and drink. They show no change.’
Furthermore, if Allah allowed Prophet Ibrahim, Prophet Musa, and Prophet Isaa to perform certain miracles, then allowing al-Mahdi to live for such an extended period of time is not difficult for Him, for He is capable of doing all things.
 Sahih al-Bukhari, Vol. 4, 143
 Sahih Muslim, Vol. 2; Sunan Tirmidhi; Sunan Abu Dawud, Vol. 2, 421
 Sunan Abu Dawud, Vol. 2; 421
 Ibid., Vol. 2, Hadith 4082 and 4087
 Ibid., Vol. 2, Hadith 4082 and 4087
 Tirmidhi, al-Jami‘al-Sahih, Vol. 9, 74-75; For more references on this topic see: Fath al-Bari, al-Hafiz, Vol. 5. 362; Ibn Hajar al-Haythami, al-Sawa’iq Vol. 2, 212; Muntakab al-Athar, Ayatullah Lutfullah Safi, which includes over sixty hadiths from the Sunni sources and ninety hadiths from the Shi΄a sources.
 Noble Qur’an, 2:259