Etiquette of Sleeping or Lying Down in the Mosque
When sleeping in the mosque is permissible when needed, then lying down for a short while merely to rest and relax cannot be impermissible. Rather, the evidence for lying down in the mosque is found in authentic hadiths from the Prophet ﷺ himself. However, since it is a mosque, one should observe the etiquette that is necessary, out of regard for its sanctity and respect.
For example, spreading out a rug, mat or mattress and the like, wearing clothing in which there is no fear of being exposed, and certainly wearing underwear, so that, in the case of a wet dream, the floor of the mosque or the rug, row-mat or carpet and the like spread upon it remains protected from every kind of impurity.
Stretching out the legs and placing one on the other:
The manner of lying down in the mosque is itself established from the Prophet ﷺ. For the one who adopts it, the chances of being uncovered or of the private parts being exposed are, if not eliminated, at least reduced.
Thus, in Sahih al-Bukhari and Sahih Muslim, Sharh al-Sunnah of al-Baghawi and Muwatta Imam Malik, Abbad bin Tamim narrates from his paternal uncle (Abdullah bin Zayd bin Asim al-Mazini, may Allah be pleased with him) that he said:
إنه رأى رسول الله صلى الله عليه وسلم فى مسجد وضع إحدى رجليه على الأخرى
I saw the Prophet ﷺ lying down in the mosque in such a manner that he ﷺ had placed one blessed foot on the other.
While in Sahih al-Bukhari and Muwatta Imam Malik, Sa’id bin al-Musayyib (may Allah have mercy on him), and in Sharh al-Sunnah of al-Baghawi, Ibn Shihab al-Zuhri (may Allah have mercy on him), said:
ان عمر بن الخطاب وعثمان بن عفان رضي الله عنهما يفعلان ذلك
Umar and Uthman (may Allah be pleased with him) used to do this.
And al-Humaydi (may Allah have mercy on him) has narrated from Ibn Mas’ud (may Allah be pleased with him), along with this action of Umar al-Faruq (may Allah be pleased with him) and Uthman (may Allah be pleased with him), the same action of Abu Bakr al-Siddiq (may Allah be pleased with him) as well.
From this it is known that lying down in this manner and placing one foot on the other is also permissible. Imam al-Baghawi and Allamah Wahid al-Zaman (may Allah have mercy on him) write that if one lies on his back with his legs stretched out, no knee raised, and the clothing is also covering, then the private part is not exposed; rather, this will be more covering than placing the legs stretched out separately.
Likewise, Imam al-Khattabi and al-Bayhaqi, Imam al-Nawawi, Hafiz Ibn Hajar, Allamah al-Zurqani and other people of knowledge have also declared this manner of lying on the back permissible.
An apparent contradiction and its resolution:
There is also a prohibition against lying on the back with one foot placed on the other, in a hadith found in Sahih Muslim and other books of Sunan, in which Jabir (may Allah be pleased with him) narrates:
إن رسول الله صلى الله عليه وسلم نهى عن أن يرفع الرجل إحدى رجليه على الأخرى وهو مستلق على ظهره
The Prophet ﷺ forbade a person from raising one of his feet and placing it on the other while lying on his back.
And the words of another narration are:
ولا تضع إحدى رجليك على الأخرى إذا استلقيت
When you are lying on your back, do not place one of your feet on the other.
And in a third narration:
لا يستلقين أحدكم ثم يضع إحدى رجليه على الأخرى
None of you should lie on his back and then place one of his feet on the other.
Imam al-Nawawi (may Allah have mercy on him) writes in Sharh Muslim that:
This prohibition is to be understood as referring to the form in which a person, lying on his back, raises his knee and places the other foot on top of it, as can happen when one is alone. The reason for its prohibition is that doing so brings the fear of the private parts being exposed.
And regarding the first, permissible form that was mentioned, he writes that:
If there is no exposure, there is no harm or dislike in lying on the back in this way. And the Prophet’s ﷺ lying in this manner may have been to show permissibility, as if to say: I had forbidden you from lying on your back and placing foot on foot, but if you must lie like this, then place one foot on the other in this way (and do not raise the knee).
And, quoting from al-Qadi, he writes that:
It is possible that the Prophet ﷺ adopted even the form of lying on his back with one foot on the other merely because of tiredness and for the sake of comfort; otherwise, generally the blessed habit of the Prophet ﷺ was that he ﷺ would sit among people in various ways. He would not lie down.