The Holy Prophet (PBUH) of Islam, on his way back from his last pilgrimage to Mecca, received some commandments from God through Gabriel. Two of these commandments were: "O Prophet! Declare what you were commanded to" and "Your Prophetic mission is not incomplete unless you declare the commandment of God".
There would have been no word of Mahdi had the Prophet not introduced him because the people disobeyed divine order about the Velayat of Ali and did everything they could to fade the light of Imamate throughout history. They killed some, imprisoned some, and made some refugees, unaware that God has destined the believers to dominate the world though disbelievers may not like it. The divine religion will ultimately materialize the promise made in the Holy Book.
God promises the good-doers to inherit the earth and establish the religion He has approved: "And we desired to bestow a favor upon those who were deemed weak in the land, and to make them the Imams, and to make them the heirs." (28: 5)
The religion chosen by God is surely the one He named Islam and approved of on the Ghadir day. This religion will not be established unless through knowing its founders and obeying their commandments. History shows the steps taken by the successors of the Prophet (PBUH) to prepare for establishment of religion preferred by God.
It is clear from the Ghadir Sermon of the Holy Prophet (PBUH) that he took that important occasion, i.e. his last pilgrimage to Hajj to make a crucial, vital announcement. The announcement in fact was for the future generations to be able to identify his righteous successors. Not only the immediate successor, that is, Imam Ali but also his last successor, that is Imam Mahdi who will reappear to fill the world with justice and uproot injustice and oppression.
source : www.tebyan.net