It is narrated from Hazrat Abu Dharr (may Allah be pleased with him) that once I asked the Holy Prophet (peace and blessings be upon him): "Which was the first mosque built on earth?" The Holy Prophet (peace and blessings be upon him) replied: "Masjid al-Haram." I asked: "Then which one?" He replied: "Masjid al-Aqsa." I asked: "What was the interval between the two?" The Holy Prophet (peace and blessings be upon him) replied: "Forty years." I asked: "Then which mosque?" The Holy Prophet (peace and blessings be upon him) replied: "Then, wherever you find the time for prayer, perform it there, for the whole earth is a mosque."
Hadith Referenceمسند احمد / مسند الأنصار رضي الله عنهم / 21383