Sayyiduna Abu Dharr (may Allah be pleased with him) narrates that I asked, "O Messenger of Allah, which mosque was built first on the earth?" The Prophet (peace and blessings be upon him) replied: "Al-Masjid al-Haram." I asked, "Then which was built after that?" The Prophet (peace and blessings be upon him) replied: "Al-Masjid al-Aqsa." I asked, "What was the time span between the two?" The Prophet (peace and blessings be upon him) replied: "Forty years. Then, wherever you may be when the time for prayer comes, perform the prayer there, for that is a mosque." This is the hadith of Abu Mu'awiyah (all the teachers of the Imam have narrated the hadith with the same meaning). Imam Abu Bakr (may Allah have mercy on him) says that the hadiths of the Prophet (peace and blessings be upon him) stating, "The whole earth has been made a mosque and a means of purification for us," are related to this chapter.
Hadith Referenceصحيح ابن خزيمه / جماع أبواب المواضع التى تجوز الصلاة عليها، والمواضع التى زجر عن الصلاة عليها / 787
Hadith Takhrijصحيح مسلم
Explanation & Benefits
Shaykh Muhammad Farooq Rafi
Benefits: Among the special characteristics of this Ummah is that the entire surface of the earth has been made a place of worship (masjid) for them. Therefore, wherever the time for prayer occurs, it is permissible to perform the prayer there. It is not obligatory to restrict the performance of prayer to mosques. This narration is general, but according to subsequent narrations, some places are excepted where performing prayer is disliked (makruh) or impermissible. Therefore, the preferred understanding is that, except for the disliked and prohibited places, it is permissible and legislated to perform prayer everywhere.
Source: Sahih Ibn Khuzaymah: Commentary by Muhammad Farooq Rafee, Page: 787