I said, "O Allah's Messenger (ﷺ)! Which mosque was built first?" He replied, "Al-Masjid-ul-Haram." I asked, "Which (was built) next?" He replied, "Al-Masjid-ul-Aqs-a (i.e. Jerusalem)." I asked, "What was the period in between them?" He replied, "Forty (years)." He then added, "Wherever the time for the prayer comes upon you, perform the prayer, for all the earth is a place of worshipping for you."
Reference: Sahih al-Bukhari 3425 In-book : Book 60, Hadith 97 USC-MSA web (English) : Vol. 4, Book 55, Hadith 636 (deprecated)
Help us gift a modern, ad-free Islamic application for the Muslim Ummah. Your donation will be recorded as Sadaqah Jariyah in your book of deeds, In Sha Allah.