Narrated Abu Dhar: I said, “O Allah’s Messenger! Which mosque was first built on the surface of the earth?” He said, “Masjid-ul-Haram (at Makkah).” I said, “Which was built next?” He replied, “Masjid-ul-Aqsa (at Jerusalem).” I said, “What was the period of construction between the two?” He said, “Forty years.”
He added, “Wherever (you may be, and) the Salat (prayer) time becomes due, perform the Salat (prayer) there, for the best thing is to do so (i.e. to offer the Salat in time).”
[4: 585- O.B. Sahih Al-Bukhari)