Abdullah ibn Amr reported: The Messenger of Allah, peace and blessings be upon him, said, “When Solomon, son of David, peace and blessings be upon him, built the Sacred House, he asked Allah Almighty for the three things throughout. Solomon asked Allah Almighty for judgment coinciding with His judgment, and he was given it. Solomon asked Allah Almighty for a kingdom none would have after him, and he was given it. And Solomon asked Allah Almighty when he finished the foundations of the Mosque that none would come to it, intending only to pray, but that his sins would be expunged like the day he was born from his mother.”
Source: Sunan al-Nasā’ī 693
Grade: Sahih (authentic) according to Al-Albani
عَنْ عَبْدِ اللَّهِ بْنِ عَمْرٍو عَنْ رَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ أَنَّ سُلَيْمَانَ بْنَ دَاوُدَ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ لَمَّا بَنَى بَيْتَ الْمَقْدِسِ سَأَلَ اللَّهَ عَزَّ وَجَلَّ خِلَالًا ثَلَاثَةً سَأَلَ اللَّهَ عَزَّ وَجَلَّ حُكْمًا يُصَادِفُ حُكْمَهُ فَأُوتِيَهُ وَسَأَلَ اللَّهَ عَزَّ وَجَلَّ مُلْكًا لَا يَنْبَغِي لِأَحَدٍ مِنْ بَعْدِهِ فَأُوتِيَهُ وَسَأَلَ اللَّهَ عَزَّ وَجَلَّ حِينَ فَرَغَ مِنْ بِنَاءِ الْمَسْجِدِ أَنْ لَا يَأْتِيَهُ أَحَدٌ لَا يَنْهَزُهُ إِلَّا الصَّلَاةُ فِيهِ أَنْ يُخْرِجَهُ مِنْ خَطِيئَتِهِ كَيَوْمِ وَلَدَتْهُ أُمُّهُ
693 سنن النسائي كتاب المساجد فضل المسجد الأقصى والصلاة فيه
692 المحدث الألباني خلاصة حكم المحدث صحيح في صحيح النسائي