Language:
كتاب أحاديث الأنبياء
60
Prophets
(10)
Chapter:
(10)
باب

Narrated Abu Dhar:

I said, "O Allah's Messenger (ﷺ)! Which mosque was first built on the surface of the earth?" He said, "Al- Masjid-ul-,Haram (in Mecca)." I said, "Which was built next?" He replied "The mosque of Al-Aqsa ( in Jerusalem) ." I said, "What was the period of construction between the two?" He said, "Forty years." He added, "Wherever (you may be, and) the prayer time becomes due, perform the prayer there, for the best thing is to do so (i.e. to offer the prayers in time).

حَدَّثَنَا مُوسَى بْنُ إِسْمَاعِيلَ، حَدَّثَنَا عَبْدُ الْوَاحِدِ، حَدَّثَنَا الأَعْمَشُ، حَدَّثَنَا إِبْرَاهِيمُ التَّيْمِيُّ، عَنْ أَبِيهِ، قَالَ سَمِعْتُ أَبَا ذَرٍّ ـ رضى الله عنه ـ قَالَ قُلْتُ يَا رَسُولَ اللَّهِ، أَىُّ مَسْجِدٍ وُضِعَ فِي الأَرْضِ أَوَّلُ قَالَ ‏"‏ الْمَسْجِدُ الْحَرَامُ ‏"‏‏.‏ قَالَ قُلْتُ ثُمَّ أَىٌّ قَالَ ‏"‏ الْمَسْجِدُ الأَقْصَى ‏"‏‏.‏ قُلْتُ كَمْ كَانَ بَيْنَهُمَا قَالَ ‏"‏ أَرْبَعُونَ سَنَةً، ثُمَّ أَيْنَمَا أَدْرَكَتْكَ الصَّلاَةُ بَعْدُ فَصَلِّهْ، فَإِنَّ الْفَضْلَ فِيهِ ‏"‏‏.‏
Reference : Sahih al-Bukhari 3366
In-book reference : Book 60, Hadith 45
USC-MSA web (English) reference : Vol. 4, Book 55, Hadith 585
  (deprecated numbering scheme)