Abdullah bin Amr bin As reported,

The Messenger of Allah ﷺ said, "When Sulayman bin Dawud ﷺ built the Sacred House in Jerusalem, he asked Allah عز وجل for three things. He asked Allah, the Mighty and Majestic, for judgment that would align with His judgment, and it was granted to him. He asked Allah عز وجل for a kingdom that would not be fitting for anyone after him, and it was granted to him. And when he finished building the mosque, he asked Allah عز وجل that no one come to it intending nothing but to pray within it except that he leave it cleansed of his sins as on the day his mother gave birth to him."

Azami 3081

Sahih

عن عبد الله بن عمرو

عن رسول الله ﷺ قال: إن سليمان ابن داود ﷺ لما بنى بيت المقدس سأل الله عز وجل خلالا ثلاثة: سأل الله عزوجل حكما يصادف حكمه فأوتيه، وسأل الله عز وجل ملكا لا ينبغي لأحد من بعده فأوتيه، وسأل عز وجل حين فرغ من بناء المسجد أن لا يأتيه أحد لا ينهزه إلا الصلاة فيه أن يخرجه من خطيئته كيوم ولدته أمه.

الأعظمي 3081صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Mosques
Section
Virtue of Masjid Aqsa and prayer in it
Numbering
Jami al-Kamil 3081 (2nd edition)
Azami 3081