According to Shi'i hadiths, the beginning of the imamate of Imam al-Mahdi (a) was when he was five. God bestowed upon him the qualifications needed for imamate at that young age, just as Yahya (a) was given wisdom in his childhood, and Jesus (a) was chosen as a prophet when he was an infant.
Hadiths from the Prophet (s) and Imams (a) mention the imamate of Imam al-Mahdi (a). His father, Imam al-Hasan al-'Askari (a), specifically showed him to his trusted Shi'a and announced his imamate.
Believing in a savior is not exclusive to the Shi'a or Muslims. Many religions and sects also maintain similar beliefs. The difference between Twelver Shi'ism and the other religious traditions is the belief in a specific person, who was born in 255/869 and is still alive, as the awaited savior.
Narration from the Prophet (s)
Among the hadiths of the Prophet (s) pointing to the imamate of the twelfth Imam, recorded in Shi'i sources, is the hadith in which the Prophet (s) says to Imam al-Husayn (a), "You are the master, the son of the master; you are the Imam son of the Imam; you are the Proof son of a Proof; you are the father of nine Proofs from your progeny, the ninth of whom is the Riser (al-Qa'im)."
"Mahdi is from my family, from the descendants of Fatima.'"
"Mahdi is from us, Ahl al-Bayt."
"If only one day remains before the world ends, God will raise a man from my family who will fill the earth with justice, while it has become full of injustice and oppression."
In a hadith recorded in al-Khwarazmi's Maqtal, the Prophet (s) declares the names of the Twelve Imams one by one and mentions Imam al-Mahdi (a) as the last Imam.
Narrations from the Imams (a)
Among the hadiths of the Imams (a), a hadith attributed to Imam 'Ali (a) states, "Know that by God, my two sons [[[al-Hasan (a)]] and al-Husayn (a)] and I will be murdered, and God will surely raise at the end of the time a man from my descendants who will revenge for us. He will be hidden from people so that the misguided should be known, [and his occultation will be prolonged] until the ignorant will say, 'God does not need the family of Muhammad [s]'."
A hadith from Imam al-Baqir (a) states, "After al-Husayn b. 'Ali (a), there will be nine imams, the ninth of whom is the Riser."
Main article: Occultation
Several hadiths predicted the birth and occultation of Imam al-Mahdi (a), before his birth. Many hadiths also speak about his rule. According to these hadiths, he is the Imam who will rise by God's command and establish a universal rule. Before his uprising, he has two periods of occultation, one of which is longer than the other. The Minor Occultation started from the birth of the Imam until 329/940, when the last "special deputy" of the Imam (a) passed away. After that, the Major Occultation started, which will end when he will rise against the injustice and oppression that fills the world.