صحيح مسلم Sahih Muslim كتاب صلاة المسافرين وقصرها The Book of Prayer - Travellers
باب مَا يَقُولُ إِذَا دَخَلَ الْمَسْجِدَ:

Chapter: What to say when entering the masjid

2 hadith
Hadith 713
حَدَّثَنَا يَحْيَى بْنُ يَحْيَى ، أَخْبَرَنَا سُلَيْمَانُ بْنُ بِلَالٍ ، عَنْ رَبِيعَةَ بْنِ أَبِي عَبْدِ الرَّحْمَنِ ، عَنْ عَبْدِ الْمَلِكِ بْنِ سَعِيدٍ ، عَنْ أَبِي حُمَيْدٍ ، أَوْ عَنْ أَبِي أُسَيْدٍ ، قَالَ : قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ : " إِذَا دَخَلَ أَحَدُكُمُ الْمَسْجِدَ ، فَلْيَقُلْ : اللَّهُمَّ افْتَحْ لِي أَبْوَابَ رَحْمَتِكَ ، وَإِذَا خَرَجَ ، فَلْيَقُلْ : اللَّهُمَّ إِنِّي أَسْأَلُكَ مِنْ فَضْلِكَ " ، قَالَ مُسْلِم : سَمِعْتُ يَحْيَى بْنَ يَحْيَى ، يَقُولُ : كَتَبْتُ هَذَا الْحَدِيثَ مِنْ كِتَابِ سُلَيْمَانَ بْنِ بِلَالٍ ، قَالَ : بَلَغَنِي أَنَّ يَحْيَى الْحِمَّانِيَّ ، يَقُولُ : وَأَبِي أُسَيْدٍ .
Abu Usaid reported that the Messenger of Allah (ﷺ) said: When any one of you enters the mosque, he should say: "O Allah! open for me the doors of Thy Mercy" ; and when he steps out he should say: 'O Allah! I beg of Thee Thy Grace." (Imam Muslim said: I heard Yahya saying: I transcribed this hadith from the compilation of Sulaiman bin Bilal (RA) ).
Hadith Reference Sahih Muslim / The Book of Prayer - Travellers / Hadith: 713
Hadith Grading محدثین: أحاديث صحيح مسلم كلها صحيحة
Hadith Takhrij «أحاديث صحيح مسلم كلها صحيحة»
Hadith 713
A hadith like this has been narrated from the Apostle of Allah (ﷺ) by Abu Usaid.
Hadith Reference Sahih Muslim / The Book of Prayer - Travellers / Hadith: 713
Hadith Grading محدثین: أحاديث صحيح مسلم كلها صحيحة
Hadith Takhrij «أحاديث صحيح مسلم كلها صحيحة»