Fiqh-us-Sunnah Volume 002, Supererogatory Prayer, Fiqh 2.073A.

Section : Permission to eat, drink, or sleep in the mosque.

Ibn 'Umar says: "During the time of the Messenger of Allah, we would sleep and take nap in the mosque, and at that time, we were young men."

An-Nawawi said: "It is confirmed that ahl as-suffah, 'Ali, Sufyan ibn Umayyah, and a number of the companions used to sleep in the mosque. Thumamah slept there before he embraced Islam. All of that was during the time of the Messenger of Allah." Ash-Shaf'i writes in al-Umm: "If a polytheist could sleep in a mosque, then definitely a Muslim can." In alMukhtasar it is said: "There is no harm in a polythiest staying in any mosque except the inviolable mosque [in Makkah]." 'Abdullah ibn al-Harith says: "During the time of the Messenger of Allah, we would eat meat and bread in the mosque." This is related by Ibn Majah with a hasan chain.

Related Hadith(s)