Prophetic Postures for Sitting and Lying: Guidance in the Light of Authentic Ahadith
This excerpt is taken from Sheikh Muḥammad Munīr Qamar’s book Aḥkām al-Masājid.
The Four Sunnah Postures of Sitting
The ways the Prophet ﷺ would usually sit were four: ihtibāʾ (اجتباء), mutarabbaʿ (تربعًا), qurfusāʾ (قرفصاء), and iqʿāʾ (اقعاء).
Sharḥ al-Nawawī 78/14/7
① Iḥtibāʾ (اجتباء)
In Arabic, this refers to sitting with the knees drawn up, which was a common posture among the Arabs, as they lived in deserts and wilderness where walls to lean on were not available. Hence they sat in this manner. From this comes the saying:
الاحتباء حيطان العرب — “Iḥtibāʾ is the ‘walls’ of the Arabs.”
Iḥtibāʾ means bringing the feet and abdomen together and binding them with the back using a garment or hands. Al-Ṭībī said: when both knees are raised with the soles on the ground, and both hands are placed on the shins, this posture is called iḥtibāʾ.
Lughāt al-Ḥadīth, vol. 1, Kitāb Ḥ, p. 15
The permissibility of this posture is known from Ṣaḥīḥ al-Bukhārī, Ṣaḥīḥ Muslim, al-Adab al-Mufrad, and al-Manāqib of al-Ḥākim, in the ḥadīth where Abū Hurayrah رضي الله عنه relates the Prophet’s ﷺ affection for Ḥasan رضي الله عنه. In it is mentioned that one day the Prophet ﷺ left his house and found me in the mosque. He took my hand, and I accompanied him to the market of Banū Qaynuqāʿ. He walked around and then returned:
حتى جئنا المسجد فجلس فاحتبى
Bukhārī with Fatḥ 339/4, 279/10; Muslim with Nawawī 193/10/8 (without the word “iḥtibāʾ”); al-Adab al-Mufrad p. 519
“Until we came back to the mosque, and he sat and performed iḥtibāʾ (sat with knees drawn up).”
The iḥtibāʾ of Abū Saʿīd رضي الله عنه is also established in Ṣaḥīḥ al-Bukhārī (with Fatḥ 541/1). However, if a person is wearing only a single garment such that sitting like this risks exposure of the ʿawrah, then this posture is prohibited. Thus, in Bukhārī, Muslim, and al-Nasāʾī, the prohibition in the ḥadīth of Abū Saʿīd al-Khudrī رضي الله عنه is understood in this context, wherein he narrates that the Prophet ﷺ forbade two types of sales and two types of clothing. In it is:
واللبسة الأخرى احتباء بثوبه وحابس ليس على فرجه منه
Bukhārī 278/10; Muslim with Nawawī 155/10/5 (without the quoted wording); Ṣaḥīḥ Abī Dāwūd 2/768–769; Tirmidhī with Tuḥfa 5/450–451; al-Adab al-Mufrad p. 515; Ṣaḥīḥ al-Nasāʾī 3/1081
“And the other prohibited way of wearing is that a person sits and performs iḥtibāʾ with his only garment while there is nothing covering his private part.”
Hence this prohibition applies specifically to the case of wearing a single sheet, as the ʿawrah may become exposed.
Lughāt al-Ḥadīth, ibid.
② Taraubuʿ / Mutarabbaʿ (تربع)
Tarbīʿ in Arabic means sitting cross-legged (fourfold), commonly called “sitting cross-legged.” In Imām al-Bukhārī’s al-Adab al-Mufrad, al-Istīʿāb (Ibn ʿAbd al-Barr), and Tahdhīb al-Kamāl (al-Mizzī), Ḥanẓalah b. Khuzaymah رضي الله عنه narrates:
آتيت النبى صلى الله عليه وسلم فرأيته جالسا متربعا
Lughāt al-Ḥadīth, ibid.
“I came to the Prophet ﷺ and saw him sitting cross-legged.”
In Ṣaḥīḥ Muslim, Abū Dāwūd, Tirmidhī, and al-Nasāʾī, Jābir b. Samurah رضي الله عنه reports:
كان النبى صلى الله عليه وسلم إذا صلى الفجر تربع فى مجلسه حتى تطلع الشمس حسناء
Muslim with Nawawī 3/5/171; Abū Dāwūd with ʿAwn 3/199; Ṣaḥīḥ Tirmidhī 479; Ṣaḥīḥ al-Nasāʾī 1281, 1285
“The Prophet ﷺ, after Fajr prayer, would sit cross-legged in his place until the sun rose bright.”
Likewise, in al-Adab al-Mufrad and Maʿānī al-Āthār (al-Ṭaḥāwī), ʿImrān b. Muslim states:
رأيت أنس بن مالك يجلس هكذا متربعا ويضع إحدى قدميه على الأخرى
al-Adab al-Mufrad, p. 517
“I saw Anas b. Mālik رضي الله عنه sitting cross-legged in this manner, placing one foot over the other.”
There are also a number of āthār indicating the permissibility and legislation of sitting cross-legged.
Lughāt al-Ḥadīth, vol. 2, Kitāb “ر”, p. 26
And from some Companions it is narrated:
لم ير متربعا قط
Ṣaḥīḥ Abī Dāwūd 4057; Ṣaḥīḥ Tirmidhī 2256; al-Adab al-Mufrad p. 517 (no posture specified); Mukhtaṣar al-Shamāʾil 101
“That the Prophet ﷺ was never seen sitting cross-legged.”
Regarding this, ʿAllāmah Waḥīd al-Zamān رحمه الله wrote that perhaps this narrator simply did not see it.
③ Qurfusāʾ (قرفصاء)
The third posture is qurfusāʾ. The Arabs say:
قرفص الرجل — “A man sat on his feet and pressed his thighs to his shins.”
This is also called asīfāz—i.e., squatting on the feet, typically for quickness or need, known as “sitting on the feet.” This posture is also established from the Prophet ﷺ. In Abū Dāwūd, Tirmidhī, al-Adab al-Mufrad, and al-Ṭabarānī, Qabīlah رضي الله عنها reports:
رأيت النبى صلى الله عليه وسلم قاعدا القرصفاء
Abū Dāwūd with ʿAwn 13/195–196; Tirmidhī with Tuḥfa 8/690 (graded ḥasan by al-Mundhirī and Abū ʿUmar b. ʿAbd al-Barr); Lughāt al-Ḥadīth vol. 5, Kitāb “ح”, p. 132; Ṣifat Ṣalāt al-Nabī (al-Albānī), p. 93
“I saw the Prophet ﷺ sitting in the posture of qurfusāʾ (squatting).”
④ Iqʿāʾ (اقعاء)
The fourth posture is iqʿāʾ, which is of two types. In Majmaʿ al-Baḥrayn it states that iqʿāʾ in prayer is to place the buttocks on the ground, raise both thighs and shins, and place both hands on the ground; Abū ʿUbayd said likewise.
This iqʿāʾ in prayer is prohibited, and it has been likened to the sitting of a dog. The Prophet ﷺ forbade sitting like this in tashahhud. In Musnad Aḥmad, al-Ṭayālisī, and Muṣannaf Ibn Abī Shaybah, Abū Hurayrah رضي الله عنه says:
نهاني خليلي صلى الله عليه وسلم عن إقعاء كاقعاء الكلب
Ṣifat Ṣalāt al-Nabī (al-Albānī), p. 93
“My intimate friend ﷺ forbade me from iqʿāʾ like the iqʿāʾ of a dog.”
The second form of iqʿāʾ is to place the toes on the ground with the feet upright and sit the buttocks on the heels. Between the two prostrations and in normal circumstances, sitting like this is permissible, as in Ṣaḥīḥ Muslim, Musnad Abī ʿAwānah, and al-Bayhaqī:
وهي سنة نبيك صلى الله عليه وسلم و كان أحيا نا يقعي
Ṣifat Ṣalāt al-Nabī, p. 90; al-Silsilah al-Ṣaḥīḥah 1/664
“This is the Sunnah of your Prophet ﷺ, and he would sometimes sit in iqʿāʾ.”
Similarly, in Muslim, Abū Dāwūd, and Tirmidhī, this permissibility is narrated from Ibn ʿAbbās رضي الله عنهما, who regarded it Sunnah. In al-Bayhaqī, it is also narrated from Ibn ʿUmar رضي الله عنهما with a ṣaḥīḥ or at least ḥasan chain.
Ṣifat Ṣalāt al-Nabī; al-Silsilah al-Ṣaḥīḥah, ibid.
Abū Isḥāq al-Ḥarbī, in his Gharīb al-Ḥadīth, with a ṣaḥīḥ chain, transmits from Imām Ṭāwūs:
إنه رأى ابن عمر و ابن عباس يقعيان
ibid.
“He saw Ibn ʿUmar and Ibn ʿAbbās رضي الله عنهما sitting in iqʿāʾ.”
Thus, these four postures of sitting were known among the Arabs, and the Prophet ﷺ would sit in these different ways at different times.
Returning to the Main Point
Ḥāfiẓ Ibn Ḥajar رحمه الله, quoting Imām al-Khaṭṭābī, writes in Fatḥ al-Bārī that the prohibition of lying with one leg over the other is abrogated, or else the prohibition must be understood for the case where there is a risk of ʿawrah exposure. Imām al-Bayhaqī and al-Baghawī also adopted this reconciliation. Ibn Baṭṭāl and his companions chose the opinion of abrogation.
Ḥāfiẓ Ibn ʿAbd al-Barr رحمه الله writes in Sharḥ al-Muwaṭṭaʾ that Imām Mālik رحمه الله first cited the prophetic practice of lying in the mosque with one leg over the other, and then the same practice from ʿUmar and ʿUthmān رضي الله عنهما. From this, it appears Imām Mālik regarded the prohibiting narrations as abrogated.
Imām al-Māzarī offered a unique view: that such lying was from the Khaṣāʾiṣ (specific to the Prophet ﷺ) and not for the general people.
However, Ḥāfiẓ Ibn Ḥajar provides an excellent analysis: the practice of the Rightly-Guided Caliphs is a clear proof that this was not among the Prophet’s ﷺ specificities; otherwise, they would not have done it—especially as this practice is abundantly transmitted from them. As for abrogation, mere possibility is not sufficient to declare something abrogated. The best approach is to restrict the prohibition to the case where, by raising the knee and placing the other leg over it, there is a fear of exposing the ʿawrah; and to understand permissibility for the case where, by extending the legs and placing one over the other, there is no risk of exposure.
This is also supported by Imām al-Bayhaqī, al-Baghawī, and other ḥadīth scholars and is the preferred view. Imām al-Khaṭṭābī and Imām al-Baghawī further state that the earlier ḥadīths indicate the permissibility of leaning in the mosque and reclining in any manner for rest.
For details: Fatḥ al-Bārī 1/563; Sharḥ al-Sunnah 2/276–375; Sharḥ al-Zurqānī 6/353
② Not Lying Prone (on the Stomach)
Among the etiquettes of sleeping or lying—whether in the mosque, at home, or anywhere—is not to lie on the stomach. In Sunan Abī Dāwūd (Kitāb al-Adab, Bāb al-Rajul Yantaṭbiḫ ʿalā Baṭnihi), Yaʿīsh b. Ṭuḥfah b. Qays al-Ghifārī, from his father Ṭuḥfah رضي الله عنه, and likewise in al-Nasāʾī, Ibn Mājah, al-Adab al-Mufrad, and Sharḥ al-Sunnah (muʿallaq), it is narrated:
“I was lying on my stomach in the mosque, so the Prophet ﷺ took hold of my foot and shook it, saying:
إنها ضجعة يبغضها الله”
Ṣaḥīḥ Ibn Mājah 2/305; al-Adab al-Mufrad 1187; Sharḥ al-Sunnah 2/378; al-Albānī in Ḍaʿīf Abī Dāwūd: ‘the phrasing about lying on the belly is ṣaḥīḥ’; ʿAwn al-Maʿbūd 13/380
A corroborating narration in Tirmidhī (Kitāb al-Adab, Bāb Karāhiyat al-Iḍṭijāʿ ʿalā al-Baṭn) states Abū Hurayrah رضي الله عنه reported:
رأى رسول الله صلى الله عليه وسلم رجلا مضطجعا على بطنه فقال: إن هذه ضجعة لا يحبها الله
Tirmidhī with Tuḥfa 8/51; al-Arnāʾūṭ on Sharḥ al-Sunnah 2/378: chain is ṣaḥīḥ
Another narration in Sunan Ibn Mājah from Abū Dharr al-Ghifārī رضي الله عنه:
مر بي النبى صلى الله عليه وسلم وأنا مضطجع على بطني فركضني برجله وقال: يا جنيدب إنما هذه ضجعة أهل النار
Ṣaḥīḥ Ibn Mājah 2/305
A similar report is in al-Adab al-Mufrad (al-Bukhārī) and Ibn Mājah from Abū Umāmah رضي الله عنه:
فإنها نومة جهنمية
Ḍaʿīf Sunan Ibn Mājah, p. 302; al-Adab al-Mufrad, p. 251 (Awqāf al-Imārāt ed.)
—though this chain is weak.
Given these authentic and firm narrations, those men and women accustomed to sleeping on their stomachs should reconsider their habit, even if they feel they cannot sleep otherwise. This claim holds no weight, because within a few days one can abandon a bad habit and adopt the Sunnah posture of sleeping. A few days of discomfort is certainly far better than continual divine displeasure. Where elders persist in this impermissible way, children will surely imitate. Hence, people should seriously reflect and immediately abandon this reprehensible habit. If this habit is only among children, then parents should firmly prevent them from sleeping this way, so that they neither incur Allah’s displeasure for life nor should any share of the lack of proper upbringing fall upon the parents. نسأل الله العافية
③ Lying on the Right Side
From the etiquettes of sleep—whether in the mosque or elsewhere—is to lie on the right side, as this is Sunnah and beloved to the Prophet ﷺ. In Ṣaḥīḥ al-Bukhārī, Ṣaḥīḥ Muslim, Abū Dāwūd, Tirmidhī, al-Adab al-Mufrad, ʿAmal al-Yawm wa al-Laylah (al-Nasāʾī), Musnad Abī ʿAwānah, and Musnad Aḥmad, al-Barāʾ b. ʿĀzib رضي الله عنه narrates that the Prophet ﷺ said to me:
إذا آتيت مضجعك فتوضأ وضوءك للصلاة ثم اضطجع على شقك الأيمن
“When you come to your bed for sleep, perform wuḍūʾ as you do for prayer, then lie on your right side.”
And then he instructed to recite this supplication:
اللهم أسلمت نفسي إليك ووجهت وجهي إليك وفوضت أمري إليك وألجأت ظهري إليك رغبة ورهبة إليك ولا ملجأ ولا منجا منك إلا إليك آمنت بكتابك الذى أنزلت، وبنبيك الذى أرسلت
After teaching this duʿāʾ, he ﷺ said these should be your last words before sleep:
فإن مت من ليلتك مت على الفطرة
Mukhtaṣar Muslim (al-Mundhirī) 1896; Bukhārī with Fatḥ 1315; Ṣaḥīḥ Abī Dāwūd 4219; Ṣaḥīḥ al-Tirmidhī 2703; al-Adab al-Mufrad pp. 533–534; ʿAmal al-Yawm wa al-Laylah (al-Nasāʾī) p. 460 (Dr. Fārūq Ḥammād, Marrakesh); al-Kalim al-Ṭayyib (Ibn Taymiyyah) ed. al-Albānī p. 41; Ṣaḥīḥ al-Adhkār (Abū ʿUbaydah ʿAbd al-ʿAzīz) 71; Ibn Mājah 3876
④ Placing the Right Cheek on the Right Palm
Another etiquette of sleeping is to place the right cheek on the right hand’s palm while lying on the right side. In Ṣaḥīḥ Muslim (209), Abū Dāwūd and Tirmidhī (Sunan and Shamāʾil), al-Nasāʾī (Sunan and ʿAmal al-Yawm wa al-Laylah), Muṣannaf Ibn Abī Shaybah, Ibn Mājah, Musnad Abī Laylā, Musnad Aḥmad and al-Bazzār, al-Adab al-Mufrad, and ʿAmal al-Yawm wa al-Laylah (Ibn al-Sunnī), from al-Barāʾ b. ʿĀzib رضي الله عنه, Ḥudhayfah b. al-Yamān رضي الله عنه, and Umm al-Muʾminīn Ḥafṣah bint ʿUmar رضي الله عنها:
أن النبى صلى الله عليه وسلم كان إذا أراد أن يرقد وضع يده اليمنى تحت حده، ثم يقول اللهم قني عذابك يوم تبعث عبادك
Ṣaḥīḥ Abī Dāwūd 4218; Ṣaḥīḥ Tirmidhī 2700; al-Nasāʾī (ʿAmal) pp. 449, 453; Ṣaḥīḥ al-Adhkār p. 70; al-Adab al-Mufrad p. 536; Ibn Mājah 3877; al-Kalim al-Ṭayyib p. 39; Ibn al-Sunnī p. 266, ḥadīth 737; Aḥmad 5/382, 6/288
⑤ Supplications (Duʿāʾ) at Bedtime and Upon Waking
Among the adhkār of sleep are many authentic supplications. From them:
- باسمك أموت وأحيا
“O Allah! In Your Name I die (sleep) and I live (wake).”
Upon waking:
- الحمد لله الذى أحيانا بعد ما أماتنا وإليه النشور
“All praise is for Allah Who revived us after causing us to die (sleep), and to Him is the resurrection.”
Bukhārī 6324; Ṣaḥīḥ Abī Dāwūd 4222; Ṣaḥīḥ Tirmidhī 2718; Ibn Mājah 3880; ʿAmal al-Yawm wa al-Laylah pp. 447–448; al-Kalim al-Ṭayyib p. 36; Ṣaḥīḥ al-Adhkār p. 69
These same words (first part of the duʿāʾ) are narrated from al-Barāʾ b. ʿĀzib رضي الله عنه in Ṣaḥīḥ Muslim, Musnad Aḥmad, and ʿAmal al-Yawm wa al-Laylah (al-Nasāʾī), and from Abū Dharr al-Ghifārī رضي الله عنه in Ṣaḥīḥ al-Bukhārī, ʿAmal al-Yawm wa al-Laylah (al-Nasāʾī) and others.
Muslim with Nawawī 2/17/30; Bukhārī 6325; ʿAmal al-Yawm wa al-Laylah (al-Nasāʾī) pp. 447–448; Ṣaḥīḥ Abī Dāwūd 4228
Reciting the three sūrahs at bedtime: ﴿قل هو الله أحد﴾, ﴿قل أعوذ برب الفلق﴾, ﴿قل أعوذ برب الناس﴾ — The Prophet ﷺ would cup his hands, blow into them, recite these sūrahs, and wipe over his body, starting from the head and face and the front of the body, doing this three times.
Bukhārī 6319; Ṣaḥīḥ Abī Dāwūd 4228; ʿAmal al-Yawm wa al-Laylah p. 462; al-Kalim al-Ṭayyib pp. 36–37; Ṣaḥīḥ al-Adhkār p. 69
Āyat al-Kursī at bedtime: ﴿الله لا إله إلا هو الحي القيوم﴾ … to the end. A guardian is appointed, and Satan and thieves will not approach until morning. The Prophet ﷺ said about the informant:
صدقك وهو كذوب ذاك الشيطان
Bukhārī with Fatḥ 4/487, ḥadīth 5010
The last two āyāt of Sūrat al-Baqarah at night suffice:
من قرأ الآيتين من آخر سورة البقرة فى ليلة كفتاه
Bukhārī 5009; Mukhtaṣar Muslim (al-Mundhirī) 2097; al-Kalim al-Ṭayyib p. 37
Tasbīḥ of Fāṭimah رضي الله عنها at bedtime: 33 times Subḥānallāh, 33 times Al-ḥamdu lillāh, 34 times Allāhu akbar—better than a servant.
Bukhārī 5362; Muslim with Nawawī 17/45–46; Ṣaḥīḥ Abī Dāwūd 4232; Ṣaḥīḥ Tirmidhī 2713; ʿAmal al-Yawm wa al-Laylah pp. 473–474; al-Kalim al-Ṭayyib pp. 38–39; Ṣaḥīḥ al-Adhkār p. 70
(ʿAlī رضي الله عنه said: from that day he never left it—even on the night of Ṣiffīn.)
⑥ If You Wake, Shake the Bed Before Lying Down Again
From the etiquettes: if a person wakes up and gets off the bed, then intends to sleep again, shake or dust the bed. In Ṣaḥīḥ al-Bukhārī, Ṣaḥīḥ Muslim, Tirmidhī, and ʿAmal al-Yawm wa al-Laylah (Ibn al-Sunnī), Abū Hurayrah رضي الله عنه narrates the Prophet ﷺ said:
فلينفضه بطرف إزاره فإنه لا يدري ما خلفه عليه بعده
“He should dust it with the edge of his garment, for he does not know what may have come upon it after him (e.g., a harmful creature).”
And say at bedtime:
باسمك ربي وضعت جنبي وبك أرفعه فإن أمسكت نفسي فارحمها وإن أرسلتها فاحفظها بما تحفظ به عبادك الصالحين
Bukhārī with Fatḥ 7393; Mukhtaṣar Muslim 1900; Ṣaḥīḥ Abī Dāwūd 4223; Ṣaḥīḥ Tirmidhī 2707
Also, upon waking, another duʿāʾ is reported (per Tirmidhī’s version, and in Ibn al-Sunnī solely this one):
الحمد لله الذى عافاني فى جسدي ورد على روحي وأذن لي بذكره
Ṣaḥīḥ Tirmidhī 2707; al-Kalim al-Ṭayyib pp. 37–38; Ṣaḥīḥ al-Adhkār p. 70
⑦ Sleeping with Wuḍūʾ and Remembering Allah
From the etiquettes is to sleep in a state of purity and with dhikr. Whoever does so and wakes during the night to ask for any good of this world or the next, Allah grants it. In Abū Dāwūd, al-Nasāʾī, Ibn Mājah, Musnad Aḥmad, and Musnad al-Ṭayālisī, Muʿādh b. Jabal رضي الله عنه narrates the Prophet ﷺ said:
ما من مسلم يبيت على ذكر طاهرا فيتعار من الليل فيسأل الله تعالى خيرا من أمر الدنيا والآخرة إلا أعطاه الله إياه
Ṣaḥīḥ Abī Dāwūd 4216; Musnad Aḥmad 5/641; al-Nasāʾī (ʿAmal) 1137; Ibn Mājah 3881; Ṣaḥīḥ al-Jāmiʿ 3/177; Ṣaḥīḥ al-Targhīb 1/317 (Maktabat al-Maʿārif)
In Bāb al-Nawm ʿalā al-Ṭahārah, Abū Dāwūd also reports (and it appears in the Ṣaḥīḥayn and the Sunan al-Arbaʿah) from Ibn ʿAbbās رضي الله عنهما:
إن رسول الله صلى الله عليه وسلم قام من الليل فقضى حاجته قال أبو داود يعني بال فغسل وجهه ويديه ثم نام
Bukhārī 6316; Abū Dāwūd with ʿAwn 13/387; Ṣaḥīḥ Abī Dāwūd 3217
A third ḥadīth in Ṣaḥīḥ Ibn Ḥibbān from Ibn ʿUmar رضي الله عنهما:
من بات طاهرا بات فى شعاره ملك فلا يستيقظ إلا قال الملك اللهم اغفر لعبدك فلان فإنه بات طاهرا
Ṣaḥīḥ al-Targhīb 1/317 (Riyadh ed.)
A fourth report in al-Ṭabarānī al-Awsaṭ and al-Najm al-Kabīr from Ibn ʿUmar رضي الله عنهما:
طهروا هذه الأجساد فيطهركم الله فإنه ليس من عبد يبيت طاهرا إلا بات معه فى شعاره ملك لا ينقلب ساعة من الليل إلا قال: اللهم اغفر لعبدك فإنه بات طاهرا
Ṣaḥīḥ al-Jāmiʿ 4/15/2; Ṣaḥīḥ al-Targhīb 1/245 (al-Maktab al-Islāmī)
From these four narrations it is clear that among the etiquettes of sleep is to be in wuḍūʾ, and to sleep while engaged in dhikr and duʿāʾ—a practice of great virtue and blessing. The adhkār, awrād, and merits for sleeping and waking are numerous and authentically recorded; we suffice with these few.
Back to the Main Topic
The discussion began with the permissibility of sleeping in the mosque, and along with it, the necessary etiquettes of sleeping in the mosque and elsewhere have been outlined—wal-ḥamdu lillāh ʿalā dhālik.
Women Sleeping in the Mosque
To clarify: sleeping in the mosque is only in cases of need, so one must not exceed the limits. Just as it is permissible for men in necessity, it is likewise permissible for women, provided there is security from fitnah and proper arrangements. As mentioned earlier, there is the ḥadīth about a righteous woman who used to clean Masjid al-Nabawī, for whom a tent was set up in the mosque where she lived.
Another proof is the ḥadīth in Ṣaḥīḥ al-Bukhārī, Ibn Ḥibbān, and Ṣaḥīḥ Ibn Khuzaymah from Umm al-Muʾminīn ʿĀʾishah رضي الله عنها, who narrated the story of a slave-girl freed by her masters. While she was still with them, a little girl came wearing a red necklace; it was placed somewhere or fell off, and a kite swooped, mistaking it for meat, and flew away with it. After searching, they accused the slave-girl of theft and searched every part of her body, even her private area. She said:
فدعوت الله أن يبرئني
“Then I supplicated Allah to prove my innocence.”
She continued: by Allah, as I was standing among them, the kite returned and dropped the necklace right in their midst. I said: this is the thing you accused me of; I am free of it. She then came to the Prophet ﷺ and embraced Islam. ʿĀʾishah رضي الله عنها said:
فكان لها خباء فى المسجد أو حفش
“She had a tent in the mosque, or a small hut was made for her.”
She (ʿĀʾishah) adds that the woman used to visit her and would always recite these couplets on sitting:
ويوم الوشاح من تعابيب ربنا
ألا أنه من بلدة الكفر أنجاني
She recited them every time until ʿĀʾishah asked the reason, and the woman told her the whole incident.
Bukhārī 1/533–534 with Fatḥ 14/1/7; al-Iḥsān 4/535, 537; Ibn Khuzaymah 2/286–287
From this ḥadīth it is understood that one who has no lodging, even if a woman, may sleep in the mosque by day or night, provided that setting up a tent in the mosque does not lead to fitnah or corruption.
Fatḥ al-Bārī 1/535