The Mahdee is who will come at the end of times; he is one of the rightly-guided Khaleefahs and Imams.
A man from the inhabitants of Madeenah will flee to Makkah, and people will come to him from the dwellers of Makkah. They will bring him out (from his home), yet he will be averse to what they want of him (either because of the trials associated with being a leader or because he is fearing trials). Then they will pledge allegiance to him between the Rukn (i.e. the Black Stone) and the Maqaam (the Station of Ibraaheem).
An army will be sent to (attack) him from Sham (Syria and surrounding areas) and they will be swallowed up in Al-Baidaa — a place between Makkah and Al-Madeenah. When people see that (i.e. the honour accorded to Al-Mandee), the Abdaal from Sham will come to him and the best people from Iraq
will come and pledge allegiance to him. Then a man from the Quraish will appear; his uncles are from the children of Kalb.
He will send an army to them but they (i.e. those who pledged allegiance) will be victorious over them… Wealth will be distributed and people will apply the Sunnah of their Prophet (PBUH). Islam will achieve stability and firmness in the earth. That will last for seven years, after which the Mandee will die and the Muslims will pray over him.” (Abu Daawood)
Ali (may Allah bless him) related that the Prophet said, “A (righteous) man will come out from behind the river (i.e. from countries that lie behind it), who is called Al-Haarith ibn Harraath. At the forefront of his army will be a man called Mansoor, who will strengthen and make firm the family ( the descendants) of Muhammad (PBUH), just as the Quraish strengthened the Messenger of Allah (PBUH). It will be obligatory upon every Muslim to support him or (maybe he said) to answer him.” (Abu Daawood)
Abdullah ibn Al-Haarith ibn Juz Az-Zubaidee said, “The Messenger of Allah (PBUH), said, ‘A people from the East will come and they will strengthen and enable the Mandee — they will strengthen his rule.” (Ibn Maajah)
All the hadiths mention in the series of the article about Mahdee, affirm his coming at the end of time and what will happen when he arrived. It also noted that Mahdee will be from the descendant of Prophet Muhammed (PBUH). As a final note, he is not the one who is awaited by the Raafidah, as explained by Ibn Khateer.
Taken from Al-Bidaayah Wan-Nihaayah (The Beginning and the end)