حَدَّثَنِي أَبُو كَامِلٍ الْجَحْدَرِيُّ، حَدَّثَنَا عَبْدُ الْوَاحِدِ، حَدَّثَنَا الأَعْمَشُ، ح قَالَ وَحَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، وَأَبُو كُرَيْبٍ قَالاَ حَدَّثَنَا أَبُو مُعَاوِيَةَ، عَنِ الأَعْمَشِ، عَنْ إِبْرَاهِيمَ التَّيْمِيِّ، عَنْ أَبِيهِ، عَنْ أَبِي ذَرٍّ، قَالَ قُلْتُ يَا رَسُولَ اللَّهِ أَىُّ مَسْجِدٍ وُضِعَ فِي الأَرْضِ أَوَّلُ قَالَ ‏"‏ الْمَسْجِدُ الْحَرَامُ ‏"‏ ‏.‏ قُلْتُ ثُمَّ أَىٌّ قَالَ ‏"‏ الْمَسْجِدُ الأَقْصَى ‏"‏ ‏.‏ قُلْتُ كَمْ بَيْنَهُمَا قَالَ ‏"‏ أَرْبَعُونَ سَنَةً وَأَيْنَمَا أَدْرَكَتْكَ الصَّلاَةُ فَصَلِّ فَهُوَ مَسْجِدٌ ‏"‏ ‏.‏ وَفِي حَدِيثِ أَبِي كَامِلٍ ‏"‏ ثُمَّ حَيْثُمَا أَدْرَكَتْكَ الصَّلاَةُ فَصَلِّهْ فَإِنَّهُ مَسْجِدٌ ‏"‏ ‏.‏
Translation
Ibrahim b. Yazid al-Tayml reported

I used to read the Qur'an with my father in the vestibule (before the door of the mosque). When I recited the ayat (verses) concerning prostration, he prostrated himself. I said to him: Father, do you prostrate yourself in the path? He said: I heard Abu Dharr saying: I asked the Messenger of Allah (ﷺ) about the mosque that was first set up on the earth. He said: Masjid Harim. I said: Then which next? He said: The Masjid al-Aqsa. I said: How long is the space of time between the two? He said: Forty years. He (then) further said: The earth is a mosque for you, so wherever you are at the time of prayer, pray there.

Comment

The Book of Mosques and Places of Prayer - Sahih Muslim 520 b

This narration from Sahih Muslim contains profound wisdom regarding the sanctity of prayer spaces and the universality of worship in Islam.

Commentary on the Prostration in Unconventional Places

The initial portion demonstrates that prostration (sujūd) when reciting or hearing verses of prostration is permissible even outside formal prayer areas. The companion's action in the pathway validates performing this sunnah wherever one may be, provided the place is pure.

Historical Significance of Sacred Mosques

The Prophet's clarification that Masjid al-Haram (in Makkah) was the first mosque established on earth, followed by Masjid al-Aqsa (in Jerusalem) after forty years, establishes the primordial nature of monotheistic worship. This timeline corresponds with Islamic tradition holding that Prophet Ibrahim (Abraham) rebuilt the Ka'bah while Prophet Sulayman (Solomon) later constructed the Jerusalem mosque.

The Earth as a Mosque

The concluding statement "The earth is a mosque for you" constitutes one of Islam's most liberating principles. This teaching removes artificial barriers between sacred and profane spaces, making the entire earth a place of worship. This facilitates prayer during travel, in remote areas, and circumstances where mosques are unavailable, emphasizing that devotion depends on intention rather than location.

Legal Implications

Scholars derive from this hadith that prayer is valid anywhere on earth except specifically impure locations. This principle demonstrates Islam's practicality and accessibility, ensuring worship remains possible in all circumstances while maintaining the recommended preference for praying in congregation in mosques when feasible.