Dhikr on Entering and Leaving the Mosque
2 hadiths
When the Prophet (may Allah's peace and blessings be upon him) entered the mosque, he would say: "a‘ūdhu billāhi al-‘azhīm wa biwajhihi al-karīm wa sultānihi al-qadīm min ash-shaytān ar-rajīm" (I seek refuge in Allah, the Majestic, and in His noble Countenance, and in His eternal dominion, from the accursed devil)
‘Abdullāh ibn ‘Amr ibn al-‘Ās (may Allah be pleased with him) reported: When the Prophet (may Allah's peace and blessings be upon him) entered the mosque, he would say: "a‘ūdhu billāhi al-‘azhīm wa biwajhihi al-karīm wa sultānihi al-qadīm min ash-shaytān ar-rajīm" (I seek refuge in Allah, the Majestic, and in His noble Countenance, and in His eternal dominion, from the accursed devil) He said: "Is that all?" I said: 'Yes.' He said: "And when he says that, the devil says: "He is protected from me for the rest of the day."
When any of you enters the mosque, let him say: 'Allahumma iftah li abwāba rahmatik' (O Allah, open for me the gates of Your mercy). And when he leaves, let him say: 'Allahumma inni as’aluka min fadlik' (O Allah, I ask You of Your bounty)
Abu Humayd or Abu Usayd reported: The Messenger of Allah (may Allah’s peace and blessings be upon him) said: "When any of you enters the mosque, let him say: 'Allahumma iftah li abwāba rahmatik' (O Allah, open for me the gates of Your mercy). And when he leaves, let him say: 'Allahumma inni as’aluka min fadlik' (O Allah, I ask You of Your bounty)."