| As-salāmu ʿalaykum!|
|Turning towards Mecca|
The Imam Mahdi is just this guy, you know?
Specifically, he's a guy who will bring the return of the true Imamate in the doctrines of the Twelver sect of Shi'a Islam. Why the Imamate had to go away in the first place has never been explained, but presumably it just needed some time away to sort out its relationship with Allah.The Imam Mahdi is in no way a messiah whatsoever.
But seriously, Imam Mahdi is the twelfth and last Imam according to the doctrines of the Isna Asheri or Twelver Shia (Isna Asher literally means twelve in Arabic). It goes that his father, Hasan Al-Askari could not and did not have a son. While the Twelvers deny this claim, they also believe that Mahdi's mother did not show signs of pregnancy and that Mahdi disappeared immediately after he was born (you do the math). Mahdi only appeared once when he was five years old, to do the prayer on his father's deathbed, and then disappeared again for good; well, until he resurfaces and fills the world with justice and happiness (the Islam version of happily ever after). Twelvers also believe that Mahdi will come back on a Friday, which is the Muslim world equivalent of Sunday. So basically he will come back on a weekend and ruins it once and for all for everybody.
Last but not least, Twelvers believe that Mahdi will come back accompanied by Jesus, and together they will kill all the non-believers before they make the world a peaceful place to live. So yeah, Jesus will be there too.