What was the belief of the Family of the Prophet and the Imams regarding the Mahdi?
Following the Prophet’s death the subject of Mahdiism was also under discussion among the Prophet’s companions and the Imams. The Family of the Prophet, as the heirs to the Prophet’s knowledge and to the intricate matters concerning faith, was the most knowledgeable about the Prophetic traditions. They spoke about the Mahdi and replied to the questions that were posed to them on this subject. Let us cite some examples of these communications by them with some attention to the chronology. Although there are several traditions cited from each one of the Imams and from Fatima Zahra (peace be upon her) we will cite just one from each
(1) Tradition Narrated by Imam ‘Ali about the Future Coming of the Mahdi:
The following tradition is related by al-Asbagh who heard ‘Ali b. Abi Talib say:
The promised Mahdi will emerge at the End of Time from among us. There is no Mahdi in any nation other than him being awaited.
There are more than fifty traditions narrated from ‘Ali b. Abi Talib in connection with the future appearance of the Mahdi and his being from among the Family of the Prophet.
(2) Tradition Narrated by Fatima Zahra (peace be upon her):
Fatima Zahra told her son Husayn:
When I gave birth to you, the Prophet came to see me. He took you in his hands and said to me: “O Fatima, take your Husayn, and know that he is the father of nine Imams. From his descendants will appear righteous leaders among whom the ninth will be the Qa’im.”
(3) Tradition Narrated by Imam Hasan b. ‘Ali:
Hasan b. ‘Ali said: There will be twelve Imams following the Prophet. Nine of these Imams will be from the progeny of my brother Husayn. The Mahdi of this umma will be among them. 
(4) Tradition Narrated by Imam Husayn b. ‘Ali:
Husayn b. ‘Ali said:
Twelve Imams will be from among us. The first among them will be ‘Ali b. Abi Talib and the last will be my ninth descendant, the rightful Qa’im. Because of his blessed existence God will bring back the dead earth to life and prosperity. God will give victory to His religion over all other religions, even if this be against the liking of the disbelievers. The Mahdi will disappear from public for a while. During his occultation a number of people will abandon religion, whereas others will remain steadfast and will suffer because of their faith. This latter group will be asked tauntingly: “If your belief is true, when would your promised Imam rise?” But, remember that whoever perseveres under those unfavorable cir*****stances when enemies would falsify and harm them, their status will be like those who fought by the side of the Prophet in defending the religion of God.
(5) Tradition Narrated by Imam ‘Ali b. Husayn:
‘Ali b. Husayn said:
The birth of our Qa’im will be hidden from the people in such a way that they will assert: “He has not been born at all!” The reason for his concealment is that when he begins his revolution he will have no one’s allegiance on his neck.
(6) Tradition Narrated by Imam Muhammad Baqir:
Muhammad b. ‘Ali Baqir told Aban b. Taghlib:
I solemnly declare that the Imamate is the divine covenant that has reached us from the Prophet. The Imams after the Prophet are twelve in number of whom nine are the descendants of Husayn. At the End of Time the Mahdi will also emerge from among us who will protect the religion of God.
(7) Tradition Narrated by Imam Ja’far Sadiq:
Ja’far b. Muhammad Sadiq said:
Whoever acknowledges all the Imams, but denies the existence of the Mahdi, is like the one who acknowledges all the prophets but denies the prophethood of Muhammad (peace be upon him).
Someone asked him: “Among whose descendants is the Mahdi?” The Imam responded:
The fifth progeny of the seventh Imam [Musa Kazim] will be the Mahdi. However, he will disappear. It is not proper for you to name him.
(8)Tradition Narrated by Imam Musa Kazim:
Yunus b. ‘Abd al-Rahman asked Imam Musa b. Ja’far: “Are you the rightful Qa’im?” He replied:
Yes, I am the rightful Qa’im. But the Qa’im who will purify the earth from the enemies of God and will fill it with justice and equity, is my fifth descendant. Since he is afraid for his life, he will be in occultation for a long time. During this period of occultation, a group will turn away from religion. But some will remain steadfast in their faith.
He went on to add:
Blessed are those Shi’a who during this period of occultation will continue to be faithful to us and remain steadfast in their loyalty to us and their hostility toward our enemies. Truly, they are from us and we are from them. They are convinced about our Imamate and we acknowledge their fealty to us. By God, blessed are they! They will be with us in Paradise.
(9) Tradition Reported by Imam ‘Ali b. Musa Reza:
Rayya b. Salt once asked Imam Reza: “Are you sahib al-‘amr (Master of the Undertaking)?” The Imam said:
Yes, I am the Master of the Undertaking. However, I am not that Master of the Undertaking who will fill the earth with justice and equity. How can I be that Master of the Undertaking when you are witness to the prevalent weakness and helplessness? The promised Qa’im will be old in age but young in appearance when he emerges. He will be so powerful and strong that if he extended his hand to the most huge tree it would fall uprooted. And if he screamed among the mountains the rocks would be crushed into pieces. The rod of Moses and the seal of Solomon are with him. That person will be my fourth descendant. God will keep him in occultation for as long as He deems necessary. Then, He will cause him to appear, and through him God will fill the earth with justice and equity as it is filled with tyranny and oppression.
(10) Tradition Reported by Imam Muhammad b. ‘Ali Jawad:
Imam Muhammad Taqi Jawad told ‘Abd al-‘Azim Hasani:
Our Qa’im is the same as the promised Mahdi whom you should await and when he appears you should obey. He will be my third descendant. I swear by the God who sent Muhammad as the Prophet and appointed us as the Imams that even if there remains a single day on earth, God will prolong it until the Mahdi emerges and fills the earth with justice and equity as it is filled with injustice and tyranny. God takes care of His affairs overnight just as He managed the affairs of Moses in one night. Moses had gone to fetch fire for his family and he returned having been fully designated as God’s prophet.
The Imam then added: “Awaiting for the deliverance to come is the best act for our Shi’a.” 
11) Tradition Narrated by Imam ‘Ali Naqi:
Imam ‘Ali Naqi said: “Following me my son Hasan is the Imam, and following Hasan it will be the Qa’im who will fill the earth with justice and equity.” 
(12) Tradition Narrated by Imam Hasan ‘Askari:
Imam Hasan ‘Askari told Musa b. Ja’far Baghdadi:
I see you disputing in the matter of the Imam after me. Be aware that anyone who acknowledges the Imams after the Prophet, but rejects the Imamate of my son is like the one who has accepted the prophethood of all the prophets except the prophethood of Muhammad. The one who denies the latter is like the one who has denied all other prophets. The reason is that obedience to the last Imam is like obedience to the first Imam among us. Hence, whoever rejects the last among us is like the one who has rejected the first Imam. Let it be known to you that the occultation of my son will be so much prolonged that people will fall in doubt except for those whose faith God protects. 
Are these Traditions about the Mahdi Authentic?
Question: You can follow these traditions only if they are sound and reliable. Do you regard all these traditions about the Mahdi reliable?
Answer : I do not claim that all the traditions, on the subject of the Mahdi are highly reliable and that all its narrators are trustworthy. However, there are some among these that could be regarded as unquestionably authentic. These traditions, like all other traditions, include authentic, good, reliable, and weak cases. It is not necessary to go through the investigation of each one of them because, as you have noticed, these traditions are so numerous that any fair minded and unprejudiced person can refer to them with confidence. This confidence is based on the underlying theme in all of them that the existence of the Mahdi was among the well known subjects of Islam whose seeds were sown by the Prophet himself and whose detailed information was provided by the Imams. It is possible to maintain with certainty that in Islam there are few other subjects which could muster so many related traditions as can be summoned concerning the existence of the Mahdi.
Let me elaborate. From the beginning of his mission until the Farewell Pilgrimage, the Prophet had mentioned the subject of the Mahdi innumerable times. Following the Prophet, Imam ‘Ali, Fatima Zahra and other prominent members of the Family, had carried on the tradition of reporting about the future coming of the Mahdi. After all they were the carriers of the Prophetic knowledge. After the death of the Prophet in the year 632 CE, Muslims were counting the days for the Mahdi to appear. This led them to recognize the false pretenders who appeared from time to time in history. These traditions were reported by all schools of Islamic thought, such as the Sunnis, the Shi’is, the Ash’ari and Mu’tazili theologians, as related by the Arab, Persian, Meccan and Medinese narrators as well as those from Kufa, Basra, Baghdad, and so on. With all these traditions, which actually number more than a thousand, is it possible for any fair minded person to cast doubt in the matter of the future coming of the Mahdi by claiming that these traditions were fabricated by the extremist Shi’is and ascribed to the Prophet?
1.This number is derived from the hadith collected in Safi Gulpaygani’s Muntakhab al-athar which deals with the subject under consideration here. We shall limit ourselves to only a few examples from this compilation. Readers interested in more of these traditions should consult this important work.
2.Ithbat al-hudat, Vol. 2, p. 552. There are three more traditions here reported from Fatima Zahra.
3.Ibid., Vol. 2, p. 555. There are four other traditions reported from Imam Hasan.
4.Ibid., Vol. 2, pp. 333, 399; Majlisi, Bihar al-anwar, Vol. 51, p. 133. There are thirteen more traditions reported from Imam Husayn.
5.Bihar al-anwar, Vol. 51, p. 135. There are additionally ten traditions reported on the authority of Imam ‘Ali b. al-Husayn.
6.Ithbat al-hudat, Vol. 2, p. 559. Additionally, there are sixty-six traditions related on the authority of al-Baqir.
7.Bihar al-anwar, Vol. 51, p. 143; Ithbat al-hudat, Vol. 2, p. 404. There are one hundred and twenty-three additional traditions reported on the authority of al-Sadiq.
8.Bihar al-anwar, Vol. 51, p. 151; Ithbat al-hudat, Vol. 6, p. 417.
9.Bihar al-anwar, Vol. 52, p. 322; Ithbat al-hudat, Vol. 6, p. 420. There are additionally eighteen traditions reported on the authority of Imam ‘Ali al-Reza.
10.Bihar al-anwar, Vol. 51, p. 156; Ithbat al-hudat, Vol. 6, p. 419. There are five other traditions reported on the authority of Imam Muhammad Taqi.
11.Ithbat al-hudat, Vol. 6, p. 275. There are additionally five traditions related by Imam ‘Ali Naqi.
12.Bihar al-anwar, Vol. 51, p. 160; Ithbat al-hudat, Vol. 6, p. 427.
13.In addition, there are twenty one traditions reported on the authority of Imam Hasan ‘Askari.
Reference: Imam Al-Mahdi, The Just Leader of Humanity, Ayatollah Ibrahim Amini