Twelver Shia Islam counts a fixed line beginning with Ali, continuing through his sons Hasan and Husayn, and running through eight further descendants, among them Jafar al-Sadiq, the sixth, whose teaching gave the tradition its school of law and after whose death the Ismaili branch separated. The eleventh, Hasan al-Askari, died at Samarra in 874 under Abbasid surveillance, apparently without an acknowledged son.
Twelver doctrine holds that he had one, Muhammad al-Mahdi, concealed from birth for his protection. From 874 the Imam is held to have communicated with the community through four successive deputies, a period called the lesser occultation. In 941 the fourth deputy declared that no further deputy would be appointed and that a greater occultation had begun. The Imam is alive, hidden, and will return, with Jesus, to fill the earth with justice as it is now filled with tyranny.
Sunni Islam has its own expectation of a Mahdi as a future deliverer, but he is not identified with a particular living person and the doctrine has less structural weight. The Twelver version is closer in shape to the Jewish expectation of a messiah still to come than to either, in that a specific line and a specific person are named. It differs from the Christian claim in that the awaited figure is a guide and a restorer of justice, not a redeemer whose death effects salvation.
Claims to be the Mahdi, or to be his gate or representative, have periodically produced new movements. The Babi movement in nineteenth-century Iran, from which the Bahai Faith emerged, began with such a claim, and the Ahmadiyya movement in Punjab with another.