Fiqh-us-Sunnah Volume 2, Supererogatory Prayer, Fiqh 2.067.

Section : The earth as a mosque.

Allah the Exalted has conferred a special blessing upon this ummah – that is, the whole earth has been declared a mosque for it. Therefore, when the time for prayer comes, a Muslim may pray wherever he may be. Abu Zharr asked the Prophet, “What was the first mosque on the earth?” He said: “The Masjid al-Haram [in Makkah].” Abu Zharr asked: “which is the next oldest mosque?” The Prophet sallallahu alehi wassalam said: “The al-Aqsa Mosque.” Abu Zharr asked: “How much time was there between [the building of the two].” The Prophet sallallahu alehi wasallam replied: “Forty years.” Then, he said: “Wherever you may be, at the time of salah, you may pray for it [the earth] is all a mosque.” This is related by the group.