Short answer
Buying and selling, announcing lost property, loud worldly talk, bad smells, and anything that dirties the masjid or disturbs people praying are all disliked or forbidden in it. In the Hanafi school eating and sleeping there are disliked except for a traveller or someone in i'tikaf. Enter with respect, pray two rakats and keep it clean.
Buying and selling in the masjid is makruh tahrimi, as is raising the voice in worldly talk and entering with a bad smell. Eating, drinking and sleeping in it are makruh for anyone except a person in i'tikaf or a stranger with nowhere else to stay. Keeping it clean and fragrant is sunnah.
Other madhhabs
- Shafi'i
- Sleeping and eating in the masjid are permissible without dislike, as long as it is not dirtied.
Explanation
Allah says the masjids are His, built so His name may be remembered in them. The rules of the masjid all come back to two things: honour the house of Allah, and do not disturb the people worshipping in it.
What to avoid:
- Trade: the Prophet ﷺ told us to say to anyone buying or selling in the masjid, "May Allah not make your trade profitable". Arranging a sale by phone there is also disliked.
- Lost property: he told us to answer someone announcing a lost item with "May Allah not return it to you", because masjids were not built for that. Use the notice board or office.
- Loud worldly talk and arguments, and phones ringing. Quiet necessary talk is fine.
- Bad smells: see smoking or eating garlic before the masjid.
- Dirt: spitting, leaving rubbish, or bringing in very young children who will soil it.
- Passing in front of people praying.
Eating and sleeping: Ibn Umar, as a young unmarried man, used to sleep in the Prophet's ﷺ masjid. Hanafi scholars allow this for someone in i'tikaf and for a traveller or stranger with nowhere else to go, and dislike it for others. Iftar in the masjid in Ramadan is commonly done with the intention of i'tikaf and care to keep the floor clean. Many masjids also have a hall outside the prayer area where these rules are lighter.
What is sunnah: entering with the right foot and the du'a for entering the masjid, praying tahiyyat al-masjid, sitting facing the qibla, and making dhikr while you wait. For women during their period, see going to the mosque on your period.
The evidence
Quran, Surah Al-Jinn 72:18
وَأَنَّ ٱلْمَسَٰجِدَ لِلَّهِ فَلَا تَدْعُوا۟ مَعَ ٱللَّهِ أَحَدًۭا ﴿١٨﴾
And [He revealed] that the masjids are for Allah, so do not invoke with Allah anyone.
The masjid belongs to Allah and is for His worship.
Quran, Surah An-Noor 24:36
فِى بُيُوتٍ أَذِنَ ٱللَّهُ أَن تُرْفَعَ وَيُذْكَرَ فِيهَا ٱسْمُهُۥ يُسَبِّحُ لَهُۥ فِيهَا بِٱلْغُدُوِّ وَٱلْءَاصَالِ ﴿٣٦﴾
[Such niches are] in mosques which Allah has ordered to be raised and that His name be mentioned therein; exalting Him within them in the morning and the evenings
Masjids are to be honoured and kept for His remembrance.
Jami' at-Tirmidhi 1321
Grading to be checked... فقولوا لا أربح الله تجارتك ...
"When you see someone buying or selling in the masjid, say: May Allah not make your trade profitable."
Trade in the masjid is forbidden.
Sahih Muslim 568
Sahih... من سمع رجلا ينشد ضالة في المسجد فليقل لا ردها الله عليك ...
"Whoever hears a man announcing a lost animal in the masjid, let him say: May Allah not return it to you."
Masjids are not for worldly announcements.
Sahih al-Bukhari 440
Sahih... ينام وهو شاب أعزب لا أهل له في مسجد ...
"Ibn Umar used to sleep, as a young unmarried man with no family, in the masjid of the Prophet ﷺ."
Sleeping in the masjid is allowed for someone with need.
Where the ruling is recorded
- al-Durr al-Mukhtar, Kitab al-Salah, chapter on what is disliked in the prayer and in the masjid. Trade, eating and sleeping in the masjid are disliked except for one in i'tikaf or a stranger; raising the voice is disliked.
- al-Fatawa al-Hindiyya, Kitab al-Karahiyah, chapter on the etiquette of the masjid. Rules for keeping the masjid clean and free of worldly activity.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.