Praise be to Allah.
The texts state that the awaited Mahdi will come at the end of time, and he will be a just ruler descended from the Prophet (peace and blessings of Allah be upon him). He is not infallible, unlike the Messiah ‘Eesa (Jesus – peace be upon him), on who, according to the mutawaatir reports will come down at the end of time and will rule according to the sharee’ah of Muhammad (peace and blessings of Allah be upon him). The difference between them is that the Messiah ‘Eesa is a Prophet and the Mahdi is a just ruler. For more details on the false messiah (Dajjaal), please see Question# 8806 .
And Allah knows best.