The dua for entering the masjid is Allahumma-ftah li abwaba rahmatik: "O Allah, open for me the doors of Your mercy." When you leave, say Allahumma inni as'aluka min fadlik: "O Allah, I ask You for Your bounty." Both are from Sahih Muslim (713). Before the entering dua, send peace and blessings on the Prophet ﷺ, and step in with your right foot.
Below are the Arabic and meaning of both, a second entering dua with a remarkable promise attached, why one asks for mercy and the other for bounty, and the few manners that go with walking in: the right foot, the two rak'ahs, and a word about a popular longer version whose chain is weak.
The dua for entering the masjid
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."
Narrated by Abu Usayd (or Abu Humayd). Shortened.
Send salam on the Prophet ﷺ first
Another narration of the same hadith, in Sunan Abi Dawud, adds one step before the dua:
when any of you enters the mosque he should invoke blessing on the prophet (ﷺ) and then he should say: O Allah, open to me the gates of thy mercy.
Narrated by Abu Usayd al-Ansari. Graded sahih (al-Albani). Shortened.
Any wording of peace and blessings on him works. Two common ones are Allahumma salli 'ala Muhammad, "O Allah, send blessings on Muhammad", and as-salamu 'ala rasulillah, "peace be on the Messenger of Allah". Many people put the whole thing together at the door:
Bismillah, was-salatu was-salamu 'ala rasulillah. Allahumma-ftah li abwaba rahmatik.
"Bismillah" at the start isn't in the Muslim or Abu Dawud wording, but scholars generally see no harm in starting with Allah's name, as with most actions.
A second dua when entering
'Abdullah ibn 'Amr reported that the Prophet ﷺ said this when he entered the mosque:
when anyone says so. The devil says: he is protected from me all the day long.
Narrated by 'Abdullah ibn 'Amr via 'Uqbah ibn Muslim. Graded sahih (al-Albani). Shortened.
That's a lot of protection for one sentence: the rest of the day, not only the time you spend inside. You can say it alongside Allahumma-ftah li abwaba rahmatik; there's no fixed order between them.
The dua for leaving the masjid
Many people send salam on the Prophet ﷺ before this one too, as they do when entering. It's short, so it's usually the one new Muslims learn first.
Why mercy going in and bounty going out?
Scholars have pointed out the match between the two. Inside the masjid you're there for worship, and what you need most is Allah's mercy: forgiveness, acceptance of your prayer, nearness to Him. Outside, you're going back to work, shopping and family, and what you need there is His fadl, His bounty: provision, a living, ease in your affairs. The Quran uses the same word for what comes after Friday prayer:
فَإِذَا قُضِيَتِ ٱلصَّلَوٰةُ فَٱنتَشِرُوا۟ فِى ٱلْأَرْضِ وَٱبْتَغُوا۟ مِن فَضْلِ ٱللَّهِ وَٱذْكُرُوا۟ ٱللَّهَ كَثِيرًا لَّعَلَّكُمْ تُفْلِحُونَ ١٠
And when the prayer has been concluded, disperse within the land and seek from the bounty of Allāh, and remember Allāh often that you may succeed.
Translation: Saheeh International. Recitation: Mishary al-Afasy.
"Seek from the bounty of Allah" in that ayah is the same fadl you ask for at the door. So the two duas cover the whole of your day: mercy in worship, and bounty in the rest of life.
Right foot in, left foot out
Step in with your right foot and out with your left. Al-Bukhari puts the following hadith under the chapter heading "While entering the mosques etc. one should start with the right foot":
The Prophet (ﷺ) used to start every thing from the right (for good things) whenever it was possible in all his affairs; for example: in washing, combing or wearing shoes.
Narrated by 'A'ishah.
It's a recommended manner, not a condition of anything. If you walk in on the wrong foot, carry on. This is the reverse of the bathroom, where you go in with the left; our bathroom dua page explains that side.
Pray two rak'ahs before you sit
If anyone of you enters a mosque, he should pray two rak`at before sitting.
Narrated by Abu Qatadah al-Aslami.
This prayer is called tahiyyat al-masjid, the greeting of the mosque. It's two short rak'ahs, prayed like any two-rak'ah prayer. If the congregation is already praying, or the iqamah has been called, join them instead; that counts. If you're not yet sure how to pray two rak'ahs, our step-by-step salah guide covers it.
About the longer version with "forgive me my sins"
You'll often see a longer entering dua: Bismillah, was-salamu 'ala rasulillah, Allahummaghfir li dhunubi waftah li abwaba rahmatik, "In the name of Allah, and peace be upon the Messenger of Allah. O Allah, forgive me my sins and open for me the doors of Your mercy." It's in Sunan Ibn Majah (771), and Darussalam's editors grade that chain weak (da'if).
Nothing in it is wrong to say. Bismillah is fine, sending salam on the Prophet ﷺ is established by Abu Dawud 465, and asking for forgiveness is always good. It's only the exact combined wording that we can't attribute to the Prophet ﷺ with confidence. If you already say it, you don't need to stop; just know which parts rest on sahih hadith.
Putting it together
| When | What to do or say | Source |
|---|---|---|
| Walking in | Right foot first | Bukhari 426 (chapter heading) |
| Walking in | Send salam on the Prophet ﷺ, then Allahumma-ftah li abwaba rahmatik | Abu Dawud 465; Muslim 713 |
| Walking in (also) | A'udhu billahil-'azim wa bi wajhihil-karim... | Abu Dawud 466 (sahih) |
| Before sitting | Two rak'ahs | Bukhari 444 |
| Walking out | Left foot first, salam on the Prophet ﷺ, then Allahumma inni as'aluka min fadlik | Muslim 713 |
If you're going to a mosque for the first time and feel nervous, read our guide to visiting a mosque for the first time. It covers what to wear, where the shoes go, where men and women pray and how to introduce yourself. You don't need to have every dua memorized before you go. Say what you know, and learn the rest at your own pace. Our duas page has these and many more, and our guide on how to make dua explains the manners of asking.
Questions people ask
What is the dua for entering the masjid?
Allahumma-ftah li abwaba rahmatik, "O Allah, open for me the doors of Your mercy" (Sahih Muslim 713), after sending peace and blessings on the Prophet ﷺ (Sunan Abi Dawud 465).
What is the dua for leaving the masjid?
Allahumma inni as'aluka min fadlik, "O Allah, I ask You for Your bounty" (Sahih Muslim 713).
Which foot do you enter the mosque with?
The right foot, and you leave with the left. Al-Bukhari titles a chapter on it and gives the Prophet's habit of starting with the right (Sahih al-Bukhari 426).
Do I have to pray when I enter the mosque?
The Prophet ﷺ told us to pray two rak'ahs before sitting (Sahih al-Bukhari 444). If a congregational prayer is under way, join it instead.
Can women say the masjid dua?
Yes. The duas and manners are the same for men and women.
Is Allahummaghfir li dhunubi part of the masjid dua?
That longer wording is in Sunan Ibn Majah 771, graded weak by Darussalam. The sahih wording is Allahumma-ftah li abwaba rahmatik, after salam on the Prophet ﷺ.





