Abu Dharr reported,

I asked, "Messenger of Allah, which mosque was established on earth first?"He replied, "The Sacred Mosque."I asked, "Then which?"He said, "Then the Aqsa Mosque." Abu Muawiya said, this means Bayt al-Maqdis.I asked, "How long was the period between them?"He answered, "Forty years. And wherever the time of prayer overtakes you, pray, for it is a place of prayer."

Ahmad 21421

Sahih

حدثنا أبو معاوية حدثنا الأعمش عن إبراهيم التيمي عن أبيه

عن أبي ذر قال

قلت يا رسول الله أي مسجد وضع في الأرض أول قال المسجد الحرام قال قلت ثم أي قال ثم المسجد الأقصى قال أبو معاوية يعني بيت المقدس قال قلت كم بينهما قال أربعون سنة وأينما أدركتك الصلاة فصل فإنه مسجد

أحمد 21421صحيح
Contents
Reference
Commentary
Ayat
Collection
Musnad Ahmad
Book
Abu Dharr Ghifari
Numbering
Darussalam 21421
Ahmad 21421