Imam al-Mahdi will be a righteous man from among the descendants of Muhammad (peace and blessings of Allaah be upon him), who will appear at the end of time, through whom Allaah will set mankind’s affairs straight, and will fill the earth with fairness and justice just as it was filled with wrongdoing and oppression. His name will be the same as the name of the Prophet (peace and blessings of Allaah be upon him), and his father’s name will be the same as that of the father of the Prophet (peace and blessings of Allaah be upon him). So his name will be Muhammad ibn ‘Abd-Allaah al-Mahdi, or Ahmad ibn ‘Abd-Allaah al-Mahdi. He will be descended from Faatimah the daughter of the Messenger of Allaah (peace and blessings of Allaah be upon him), through al-Hasan ibn ‘Ali (may Allaah be pleased with him). The sign of his appearance will be widespread corruption and the earth being filled with wrongdoing and aggression.
There are a number of ahaadeeth which point to his appearance and attributes being as described above. When taken together these reports reach the level of tawaatur (i.e., narrated from so many people by so many people that it is inconceivable that they could all have agreed upon a lie). This is explained in more detail in question no. 1252.
With regard to the order in which the portents of the Hour will appear, there is some difference of opinion among the scholars, the reason being that no such order or events is narrated in the Sunnah. However the scholars have determined the order of some of the events, as follows:
1 – The appearance of the minor portents of the Hour, of which there are many which will not appear in any specific order. These include: the sending of the Prophet (peace and blessings of Allaah be upon him) and his death; the plague of ‘Amwaas; the appearance of tribulations; the loss of honesty; the disappearance of knowledge; the spread of riba, musical instruments and alcohol; regarding these things as permissible; competition in erecting tall buildings; a great deal of killing; time passing more quickly; adornment of the mosques; prevalence of shirk; the spread of immorality; a great deal of stinginess; many earthquakes; landslides, transformations and pelting with stones from the heavens; disappearance of righteous people; believers’ dreams coming true; neglect of the Sunnah; a great deal of lying; a great deal of false testimony; a great deal of sudden death; a great deal of rain but little growth of vegetation; wishing for death; increase in numbers of the “Romans” and fighting them; and other signs which are narrated in saheeh ahaadeeth from the Prophet (peace and blessings of Allaah be upon him).
2 – The appearance of the Mahdi, who will appear before the Dajjaal and before the descent of ‘Eesa ibn Maryam (peace and blessings of Allaah be upon him). This is indicated by the hadeeth of Jaabir (may Allaah be pleased with him) who said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “ ‘Eesa ibn Maryam will come down and their leader the Mahdi will say to him: ‘Come and lead us in prayer.’ But he will say: ‘No, one of them should lead the others in prayer, as a sign of honour from Allaah to this ummah.’: Narrated by al-Haarith ibn Abi Usaamah in his Musnad. And Ibn al-Qayyim said in al-Manaar al-Muneef (1/147): its isnaad is jayyid. The hadeeth is narrated with a mawsool isnaad in Saheeh Muslim, without naming their leader. Muslim’s report says: “… ‘And ‘Eesa ibn Maryam (peace and blessings of Allaah be upon him) will come down and their leader will say to him: ‘Come and lead us in prayer.’ But he will say: ‘No, one of them should lead the others in prayer, as a sign of honour from Allaah to this ummah.’” Narrated by Muslim, 225. So ‘Eesa (peace be upon him) will follow the Mahdi in prayer, which indicates that the Mahdi will appear before ‘Eesa, and ‘Eesa will kill the Dajjaal, which indicates that the Dajjaal will appear during the time of the Mahdi. See also question no. 10301.
4 – The descent of ‘Eesa ibn Maryam and his killing the Dajjaal (see question no. 10302).
5 – The appearance of Ya’jooj and Ma’jooj (Gog and Magog). One indication that Ya’jooj and Ma’jooj will emerge at the time of ‘Eesa (peace be upon him) is the hadeeth of al-Nawaas ibn Sam’aan, which says that the Prophet (peace and blessings of Allaah be upon him) told them about the Dajjaal, and said: “Whilst he is like that, Allaah will reveal to ‘Eesa: ‘I have released slaves of Mine whom no one will be able to fight. Take My slaves to safety in al-Toor (Sinai),’ and Allaah will send Ya’jooj and Ma’jooj, who will come swarming down from every mound. The first of them will pass by Lake Tiberias and will drink the water in it, and the last of them will pass by it and will say, ‘There was water here once.’” Narrated by Muslim, no. 2937.
Then the signs will come quickly, one after another. According to a hadeeth of Abu Hurayrah (may Allaah be pleased with him), the Prophet (peace and blessings of Allaah be upon him) said: “The signs will come one after another, like beads falling from a string”. Narrated by al-Tabaraani in al-Mu’jam al-Awsat; classed as saheeh by al-Albaani in Saheeh al-Jaami’. Then the sun will rise from the west, the Beast will emerge, and there will be landslides and other major signs. We ask Allaah to make us steadfast unto death. And Allaah knows best.
For more information see: al-Mahdi al-Muntazar by Dr. ‘Abd al-‘Aleem al-bastawi, 1/256; Ashraat al-Saa’ah by Yoosuf al-Waabil, p. 249. see also question no. 3259.