Mūsā ibn Ismā’īl narrated to us; ‘Abd al-Wāḥid narrated to us; al-A’mash narrated to us;
Ibrāhīm al-Taymī narrated to us from his father, who said: I heard Abū Dharr (may Allāh be content with him) say: I said, “O Messenger of Allāh ﷺ, which mosque was the first to be established on the earth?” He said: “Al-Masjid al-Ḥarām.” I said, “Then which one?” He said: “Al- Masjid al-Aqṣā.” I said, “How long was between them?” He said: “Forty years.” Then he said: “Wherever the time of prayer comes upon you, then pray there, for the virtue is in it.”
Reference: Sahih Al Bukhari 3366