Is there any Hadith with reference as to how to enter and leave the masjid?
Imam Nawawi (rahimahullah) states in Al Adhkar:
‘It is Mustahab to recite the following:
A’uzu billahil ‘azim wa bi wajhihil karim wa sultanihil qadim minash shaytanir rajim, Alhamdulillah, Allahumma salli wa sallim ‘ala Muhammad wa ‘ala aali Muhammad, Allahummagh fir li dhunubi waf tah li abwaba rahmatik
Then a person should say ‘Bismillah’ and enter with his right foot.
When exiting, A person should exit with the left foot and read the same du’a. However at the end of the du’a one should read ‘abwaba fadhlik’ instead of ‘abwaba rahmatik’
(Al Adhkar, Chapter: 20, before Hadith: 86)
The above formation of the du’a is a collection of a few narrations.
(Refer: Sahih Muslim, Hadith: 1649, Sunan Abi Dawud, Hadith: 465 and Sunan Ibn Majah, Hadith: 772)
Note: Some Hadith references mention the du’a with slight variations.
Imam Hakim (rahimahullah) has recorded a narration in his Al Mustadrak which proves entering the Masjid with the right foot and exiting with the left foot.
(Al Mustadrak, Vol. 1 pg. 218. Also refer: Sahih Bukhari and Fathul Bari, Hadith: 426)
And Allah Ta’ala Knows best.
Answered by: Moulana Suhail Motala
Approved by: Moulana Muhammad Abasoomar
Checked by: Moulana Haroon Abasoomar
This answer was collected from HadithAnswers.com. The answers were either answered or checked by Moulana Haroon Abasoomar (rahimahullah) who was a Shaykhul Hadith in South Africa, or by his son, Moulana Muhammad Abasoomer (hafizahullah), who is a Hadith specialist.