Muhammad ibn Hasan al-Mahdi (Arabic: محمد بن الحسن المهدي, romanized: Muḥammad ibn al-Ḥasan al-Mahdī), or Hujjat Allah ibn al-Hasan, is believed by the Twelver Shia to be the last of the Twelve Imams and the eschatological Mahdi, who will emerge in the end of time to establish peace and justice and redeem Islam.