Sunan an-Nasa'i, Volume 1, Book 8, Hadith 694 (DarusSalam) ⓘ
It was narrated from 'Abdullah bin 'Amr that the Messenger of Allah said: "When Sulaiman bin Dawud finished building Bait Al-Maqdis, he asked Allah for three things: Judgement that was in harmony with His judgement, and he was given that. And he asked Allah for a dominion that no one after him would have, and he was given that. And when he finished building the Masjid he asked Allah, the Mighty and Sublime, that no one should come to it, intending only to pray there, but he would emerge free of sin as the day his mother bore him."
أَخْبَرَنَا عَمْرُو بْنُ مَنْصُورٍ، قَالَ حَدَّثَنَا أَبُو مُسْهِرٍ، قَالَ حَدَّثَنَا سَعِيدُ بْنُ عَبْدِ الْعَزِيزِ، عَنْ رَبِيعَةَ بْنِ يَزِيدَ، عَنْ أَبِي إِدْرِيسَ الْخَوْلاَنِيِّ، عَنِ ابْنِ الدَّيْلَمِيِّ، عَنْ عَبْدِ اللَّهِ بْنِ عَمْرٍو، عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم " أَنَّ سُلَيْمَانَ بْنَ دَاوُدَ صلى الله عليه وسلم لَمَّا بَنَى بَيْتَ الْمَقْدِسِ سَأَلَ اللَّهَ عَزَّ وَجَلَّ خِلاَلاً ثَلاَثَةً سَأَلَ اللَّهَ عَزَّ وَجَلَّ حُكْمًا يُصَادِفُ حُكْمَهُ فَأُوتِيَهُ وَسَأَلَ اللَّهَ عَزَّ وَجَلَّ مُلْكًا لاَ يَنْبَغِي لأَحَدٍ مِنْ بَعْدِهِ فَأُوتِيَهُ وَسَأَلَ اللَّهَ عَزَّ وَجَلَّ حِينَ فَرَغَ مِنْ بِنَاءِ الْمَسْجِدِ أَنْ لاَ يَأْتِيَهُ أَحَدٌ لاَ يَنْهَزُهُ إِلاَّ الصَّلاَةُ فِيهِ أَنْ يُخْرِجَهُ مِنْ خَطِيئَتِهِ كَيَوْمِ وَلَدَتْهُ أُمُّهُ " .
also referenced under: Hadith 693 (Reference) & Book 8, Hadith 6 (In-Book)