كتاب الصلاة
4  
Prayer
(8c)
Chapter: Mosques and places of Prayer - Section 3
(7)
باب المساجد ومواضع الصلاة - الفصل الثالث
Mishkat al-Masabih 753
Abu Dharr said that he asked God’s Messenger which mosque was set up first in the earth and was told that it was the sacred mosque. He asked which came next and was told that it was the Aqsa mosque. He asked how long a space of time separated their building and the Prophet told him it was forty years, adding, “Then the earth is a mosque for you, so pray wherever you are at the time of prayer.” (Bukhari and Muslim.)
وَعَنْ أَبِي ذَرٍّ قَالَ: قُلْتُ: يَا رَسُولَ اللَّهِ أَيُّ مَسْجِدٍ وُضِعَ فِي الْأَرْضِ أَوَّلُ؟ قَالَ: «الْمَسْجِدُ الْحَرَامُ» قَالَ: قُلْتُ: ثُمَّ أَيْ؟ قَالَ: «ثُمَّ الْمَسْجِدُ الْأَقْصَى» . قُلْتُ: كَمْ بَيْنَهُمَا؟ قَالَ: «أَرْبَعُونَ عَامًا ثُمَّ الْأَرْضُ لَكَ مَسْجِدٌ فَحَيْثُمَا أَدْرَكَتْكَ الصَّلَاةُ فصل»
  مُتَّفق عَلَيْهِ   (الألباني) حكم   :
Reference : Mishkat al-Masabih 753
In-book reference : Book 4, Hadith 181