All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Al-Masjid Al-Haraam (the sacred mosque in Makkah) is the oldest mosque on the earth, then Al-Masjid Al-Aqsa.
Abu Tharr said: “I asked Allah's Messenger: Which is the oldest Mosque on earth? The Prophet said: “Al-Masjid Al-Haraam." Then I asked: which one is next? He replied: “Al-Masjid Al-Aqsa.” Then I asked: “How many years between them (i.e. of building them)?” He said: “Forty years, and pray whenever the time of any prayer comes upon you, perform the prayer, for all the earth is a place of worshipping for you.” [Al-Bukhari and Muslim]
As for the date of building Al-Aqsa, there is a difference of opinion among scholars concerning this point. But it is reported that Aadam built it first, according to Ibn Hajar and he preferred this opinion. It is also reported that Ya’qoob ibn Ishaq ibn Ibraheem was the first to build it. Then, it was rebuilt by Sulayman (Solomon) .
Allah knows best.