Our scholars accept that the Mahdi will be from among the descendants of Husayn. They refer to the following hadith reported in Sunan of Abi Dawud:
Abu Ishaq relates: “‘Ali while looking at his son Hasan said ‘This son of mine is the master (sayyid) as declared by the Prophet. Among his progeny will appear a man whose name will be that of the Prophet. He will resemble the Prophet in his demeanor; but he will not resemble him in appearance.'”
First let me point out that in all likelihood there might have occurred an error in the writing or printing of the hadith. And instead of ‘Husayn’ it might have recorded ‘Hasan’. The reason is that the same hadith has been related in other collections where instead of ‘Hasan’ it is ‘Husayn’ to whom the comment is made by ‘Ali b. Abi Talib. 
Second there are far too many hadith-reports in the Sunni and Shi’i collections that regard the Mahdi to be from among the descendants of Husayn. As such this tradition has no validity. Let us examine some examples from the Sunni compilations on this subject:
Hudhayfa relates the following hadith from the Prophet:
The Prophet said: “If there remains no more than a day for the world God will prolong it until a man from my progeny whose name will be my name will emerge.” Salman asked: “From which of your progeny will he emerge?” The Prophet replied: “From this son of mine.” And he struck Husayn with his hand. 
In another tradition Abu Sa’id Khudari relates that the Prophet (peace be upon him and his progeny) told Fatima:
“The Mahdi of this community behind whom Jesus will pray is among us.” Then he struck Husayn’s shoulder with his hand and declared: “The Mahdi of my community will be from the descendants of this son of mine.” 
Once Salman al-Farisi came to see the Prophet when the latter had Husayn in his lap. The Prophet was kissing Husayn’s face and mouth and was saying:
You are the master and the son and brother of the master. You are the Imam son and brother of the Imam. Your are the proof and son and brother of the proof of God’s existence. You are the father of nine proofs of God the ninth among whom will be the Qa’im. 
According to these hadith-reports the Mahdi is among the descendants of Husayn. Hence one should abandon those reports that say that the Mahdi will be among the descendants of Hasan. Moreover even if one accepts these latter traditions as being authentic it can be asserted that both kinds of traditions point to the fact that Mahdi is certainly the descendant of both Hasan and Husayn in the sense that Imam Muhammad Baqir’s mother was the daughter of Imam Hasan. The following hadith points to the logical connection between the two kinds of traditions about the Mahdi being from the descendants of Hasan and Husayn:
The Prophet told Fatima: The two grandsons of this community are among us. These are Hasan and Husayn who are the masters of the youths of Paradise. By God their father is more excellent than they. I solemnly declare in the name of the One who has sent me as a prophet that the Mahdi of this community will emerge from among these two sons of yours at the time when chaos will rule. 
1.Sunan Kitab al-mahdi.
2.Ithbat al-hudat Vol. 7 p. 208.
3.Dhakha’ir al-‘uqba p. 136.
4.al-Bayan fi akhbar sahib al-zaman p. 502.
5.Yanabi’ al-mawadda Vol. 1 p. 492.
6.Ithbat al-hudat Vol. 7 p. 183.
source:Al- Imam Al-Mahdi, The just leader of humanity
By: Ayatullah Ibrahim Amini