Abdullah bin Amr bin As reported,

The Messenger of Allah ﷺ said that when Sulayman bin Dawud ﷺ built Bayt al-Maqdis, he asked Allah عز وجل for three things. He asked Allah عز وجل for judgment that would align with His judgment, and he was granted it. He asked Allah عز وجل for a kingdom that would not be fitting for anyone after him, and he was granted it. And when he finished building the mosque, he asked Allah عز وجل that no one come to it intending nothing but prayer within it, except that Allah would cleanse him of his sins, leaving him as on the day his mother bore him.

Nasai 694

Sahih

أخبرنا عمرو بن منصور قال حدثنا أبو مسهر قال حدثنا سعيد بن عبد العزيز عن ربيعة بن يزيد عن أبي إدريس الخولاني عن ابن الديلمي

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

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

النسائي 694صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Mosques
Chapter
Virtue of Masjid Aqsa and prayer in it
Numbering
Darussalam 694
Nasai 694