The Mahdī will be from the bloodline of al-Ḥasan
Ali looked at his son al-Hasan and said: This son of mine is a sayyid (chief) as named by the Prophet ﷺ, and from his loins will come forth a man who will be called by the name of your Prophet ﷺ and resemble him in conduct but not in appearance. He then mentioned the story about his filling the earth with justice.
قَالَ عَلِيٌّ ؓ وَنَظَرَ إِلَى ابْنِهِ الْحَسَنِ فَقَالَ إِنَّ ابْنِي هَذَا سَيِّدٌ كَمَا سَمَّاهُ النَّبِيُّ ﷺ وَسَيَخْرُجُ مِنْ صُلْبِهِ رَجُلٌ يُسَمَّى بِاسْمِ نَبِيِّكُمْ يُشْبِهُهُ فِي الْخُلُقِ وَلاَ يُشْبِهُهُ فِي الْخَلْقِ ثُمَّ ذَكَرَ قِصَّةَ يَمْلأُ الأَرْضَ عَدْلاً