عَنْ عَبْدِ الْمَلِكِ بْنِ سَعِيدٍ بْنِ سُوَيْدٍ الْأَنْصَارِيِّ قَالَ: سَمِعْتُ أَبَا حُمَيْدٍ وَأَبَا أُسَيْدٍ يَقُولَانِ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ: إِذَا دَخَلَ أَحَدُكُمُ الْمَسْجِدَ فَلْيَقُلْ: اللَّهُمَّ افْتَحْ لَنَا أَبْوَابَ رَحْمَتِكَ، وَإِذَا خَرَجَ فَلْيَقُلْ: اللَّهُمَّ إِنِّي أَسْأَلُكَ مِنْ فَضْلِكَ
Abdul Malik bin Saeed bin Suwaid Ansari says that I heard from Sayyiduna Abu Humaid and Sayyiduna Abu Usaid (may Allah be pleased with them both), they were stating that the Messenger of Allah (peace and blessings be upon him) said: When any one of you enters the mosque, he should recite this supplication: "Allahumma iftah lana abwaba rahmatik" (O Allah! Open for us the doors of Your mercy), and when he leaves the mosque, he should recite: "Allahumma inni as'aluka min fadlik" (O Allah! I ask You for Your bounty).