According to what is indicated in various prophetic narratives (ahadith), the Mahdi (Allah bless him) will come before the Dajjal.
In the Sunan of Abu Dawud it is stated that Imam Mahdi (Allah bless him) will be given allegiance by the people between the Black Stone and the maqam of Ibrahim (Allah bless him and grant him peace). The Dajjal will then come out and would later be met by Imam Mahdi and his army (after some prior conquests) in battle, as understood from the narration of Muslim. Mulla `Ali al-Qari also states in his Mirqat,that the Dajjal will come out during the time of Imam Mahdi, indicating that the Mahdi will already be present at the time.
As for our liege-lord `Isa (Allah bless him and grant him peace), he will also descend after the appearance of Imam Mahdi (Allah bless him). Abu Hurayra (Allah be well pleased with him) states, “The Prophet (Allah bless him and grant him peace) said, ‘How will you be when the son of Mary descends among you and your leader (imam) is from amongst yourselves.”
This narration demonstrates that at the time our liege-lord `Isa (Allah bless him) descends, the Muslims will already have a leader. Many of the hadith commentators stated that this leader (imam) would be none other than the Mahdi (Allah bless him). Our liege-lord `Isa (Allah bless him and grant him peace) will pray behind him, as is is mass-transmitted (tawatur) from the Prophet (Allah bless him and grant him peace). [Ibn Hajar, Fath al Bari; Nawawi. Sharh Sahih Muslim; Kashmiri, Fayd al-Bari]