IT IS MUSTAḤABB to say: I seek protection with Allah the Tremendous and with His Noble Countenance and His Pre-eternal Sovereign Might from Shayṭān the rejected. Praise be to Allah. O Allah, send blessings and salutations upon Muḥammad and upon the family of Muḥammad. O Allah, forgive me my sins and open for me the doors of Your Mercy. Then one should say In the name of Allah. He should enter with his right foot first. He should leave with his left foot first and say all that we mentioned above, except that he should say the doors of Your Favour instead of Your Mercy.

A‘ūdhu bi-llāhi-l-‘Aẓīm, wa bi-wajhihi-l-karīm, wa sulṭānihi-l-qadīm, mina-sh-Shayṭāni-r-rajīm. Al-ḥamdu li-llāh. Allāhumma ṣalli wa sallim ‘alā Muḥammadin wa ‘alā āli Muḥammad. Allāhumma-ghfir lī dhunūbī wa-ftaḥ lī abwāba raḥmatik. Bismi-llāh.
We relate from Abū Ḥumayd, or Abū Usayd
, that the Messenger of Allah
said: “When any one of you enters the mosque, he should invoke blessings upon the Messenger
and then say: O Allah, open for me the doors of Your Mercy. And when he leaves he should say: O Allah, I ask of You from Your bounty.” [1].Muslim relates this in his Ṣaḥīḥ. Abū Dāwūd, an-Nasā’ī, Ibn Mājah and others also relate it, with a ṣaḥīḥ isnād. In Muslim’s narration there is no sentence: ‘So, send greetings upon the Prophet
’, although it is in the narrations of the rest.
Allāhumma-ftaḥ lī abwāba raḥmatik. Allāhumma innī as’aluka min faḍlik.
Ibn aṣ-Ṣunnī adds in his narration: “And when he leaves he should greet the Prophet
and say: O Allah, protect me from Shayṭān the rejected.” Ibn Mājah, Ibn Khuzaymah and Abū Ḥātim ibn Ḥibbān—with kasrah on the letter ḥā’—all narrated it in their Ṣaḥīḥs.
Allāhumma a‘idhnī mina-sh-Shayṭāni-r-Rajīm.
We relate in ‘Abdullāh ibn ‘Amr ibn al-‘Āṣ
that when the Prophet
entered the mosque he would say: “I seek protection in Allah the Tremendous, His Noble Countenance, and His Pre-eternal Sovereign Might from Shayṭān the rejected.” He remarked that if one says this then Shayṭān says: “He has gained protection from me for the whole day.” [2].This hadith is ḥasan and is narrated by Abū Dāwūd with a good isnād.
A‘ūdhu bi-llāhi-l-‘Aẓīm, wa bi-wajhihi-l-karīm, wa sulṭānihi-l-qadīm, mina-sh-Shayṭāni-r-rajīm.
We relate in the book of Ibn as-Sunnī that Anas
narrated that when the Messenger of Allah
entered the mosque he would say: “In the name of Allah. O Allah, send blessings upon Muḥammad.” And when he left he would say: “In the name of Allah. O Allah, send blessings upon Muḥammad.” [3].
We have also related the prayers upon the Prophet
as narrated by Ibn ‘Umar in the section about entering and leaving the mosque.
Bismi-llāh, Allāhumma ṣalli ‘alā Muḥammad.
We also relate from the book of Ibn as-Sunnī that ‘Abdullāh ibn al-Ḥasan reported from his mother that his grandmother said: “When the Messenger of Allah
entered the mosque he would praise Allah, mention His name, and say: ‘O Allah, forgive me and open for me the doors of Your Mercy.’ When he left he would say the same, then add: ‘O Allah, open for me the doors of Your Bounty.’” [4].
Allāhumma-ghfir lī wa-ftaḥ lī abwāba raḥmatik.
Allāhumma-ftaḥ lī abwāba faḍlik.
We relate in Abū Umāmah that the Messenger
said: “When any of you go out of the mosque, the army of Shayṭān call to one another and gather together as bees gather around their leader. So when any one of you stands at the door of the mosque he should say: O Allah, I seek Your protection from Iblīs and his armies. If he says this, then they will not harm him.” [5].The meaning of al-ya‘sūb is either male bees or their leader.
Allāhumma innī a‘ūdhu bika min Iblīsa wa junūdih.
References
[1] Muslim (713), Abū Dāwūd (465), an-Nasā’ī (2/53), Ibn as-Sunnī (85), Ibn Mājah (772), al-Ḥākim (1/207), and an-Nasā’ī in ‘Amal al-yawm wa al-laylah (90).
[2] Abū Dāwūd (466) and al-Futūḥāt (2/47). Ibn Ḥajar states that this is a ḥasan gharīb hadith, all of whose narrators but two—Ismā‘īl ibn Bishr and ‘Uqbah ibn Muslim—are trustworthy and are narrators of ṣaḥīḥ hadiths.
[3] Ibn as-Sunnī (78) and al-Futūḥāt (2/48). As-Sakhāwī states that the chain of this hadith includes unknown narrators. It is also narrated by Ibn as-Sunnī (88) from Ibn ‘Umar but here too it is very weak.
[4] Ibn as-Sunnī (86), at-Tirmidhī (314), Ibn Mājah (771), and Aḥmad (5/425). Ibn Ḥajar states that the narrators of the chain are trustworthy, but that there is a break in it. Abū ‘Īsā at-Tirmidhī states that the hadith of Fāṭimah is ḥasan, but its chain of narration is not continous. Fāṭimah bint al-Ḥusayn did not meet Fāṭimah al-Kubrā, as the latter only outlived the Prophet
by a few years. Ibn Ḥajar states that Ḥusayn’s
age at the time of his mother’s death was less than eight years.
[5] Ibn as-Sunnī (154).