What supplication is prescribed upon entering the Mosque?
Chapter on Ransom (Fidyah) and Penalty for Hunting
Al-Mughni
Book of Hajj
Primary text
It is recommended that one entering the Mosque steps in with the right foot first and then says: 'In the Name of Allah, and peace and blessings upon the Messenger of Allah, O Allah, bless Muhammad and the family of Muhammad, forgive me, and open for me the gates of Your Mercy.' This practice is supported by the tradition related from Fatima, the daughter of the Messenger of Allah, may Allah be pleased with her, that the Messenger of Allah, peace and blessings be upon him, taught her to say this upon entering the Mosque.
Supporting text
Upon exiting, one says something similar, with the variation of saying 'and open for me the gates of Your bounty' instead of mercy.