In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
2- However, a woman, either menstruating, postpartum or in istihadah, must use the proper women’s hygienic materials to prevent contaminating the mosque.
3- It is also recommended if space is limited to leave the mosque at the time of prayers to give space to other women to perform prayers.
Answering your question, Dar Al-Ifta Al-Misriyyah, states:
It is permissible for women during menses or postpartum and anyone in a state of janabah to enter the mosque either to pass by, fulfill a need, attend educational classes and the like. This is because there is no prohibition mentioned in this respect.
This opinion is maintained by Ibn Hazm, Al-Muzani from the Shafi`is and Dawud. They based their opinion on a number of evidences. These include what Ibn Hazm reported in his book Al-Muhalla bil Athar. He said: “The mother of the believers, lady Aishah (may God be pleased with her) narrated: ‘There was a black female slave owned by an Arab tribe and they freed her. The girl came to Prophet Muhammad (peace be upon him) and embraced Islam. She had a tent or a small room with a low roof in the mosque.’”
The above narration illustrates that the woman was permitted a space inside the mosque of the Prophet (peace be upon him) while it is normal for females to menstruate. However, the Prophet did not prevent or prohibit her from staying in the mosque.
In another report, Abu Hurairah (may God be pleased with him) narrated that the Prophet (peace be upon him) met him in one of the streets of Madinah while he (Abu Hurairah) was in a state of janabah. So he hurried away and took a ritual bath (ghusl, to remove the metaphysical state of impurity). The Prophet noticed his absence, and when he came back, the Prophet (peace be upon him) asked: ‘Where were you, O Abu Hurairah?’ He replied: ‘O Messenger of God, you met me while I was in a state of janabah, and I did not want to sit in your presence until I had performed ghusl.’ The Prophet said: ‘Subbhan Allah (Glory is to God)! The believer never becomes impure (najis)’” (Al-Bukhari and Muslim).
Through this report, the Prophet (peace be upon him) denied Abu Hurairah’s refusal of attending knowledge class inside the mosque due to being in a state of janabah.
The people of Suffah used to stay overnight inside the mosque in the presence of Prophet Muhammad (peace be upon him) and certainly they included those who had wet dreams. The Prophet, however, never prohibited them from staying overnight inside his mosque.
On the other hand, some jurists have maintained that it is impermissible for women in menses and postpartum and anyone in a state of janabah to enter the mosque except if there is a necessity such as passing by, seeking protection against outside harm etc. However, some other jurists have completely prohibited entering the mosque in these cases.
It is necessary to clarify the degree and classification of the hadith upon which these jurists prevented menstruating women and people in a state of janabah to enter the mosque. Abu Dawud, Ibn Majah, Al-Baihaqi and Ibn Khuzaimah reported that Aishah (may God be pleased with her) narrated that Prophet Muhammad (peace be upon him) said, “The mosque is not permitted for menstruating women or anyone who is in a state of janabah.”
All the narrators mentioned in the hadith chain of transmission are unreliable and their narrations are deemed weak. Chain of transmission included Jassrah bint Dajjah, and Al-Bukhari commented that she knows wondrous things. Al Baihaqi commented that her narrations need to be reconsidered.
In his book al-Jarh wa al-Ta`deel, Ibn Abu Hatim mentioned that the chain of narration includes Fleit Ibn Khalifa who reported from Jassrah through Aishah, and Fliet is unknown.
The entire text of the hadith is declared to be weak. This was maintained by Al-Khattabi in Ma`alim al-Sunan, Ibn al-Qayyim in Tahdhib al-Sunan, Al-Nawawi in Al-Majmu` and Ibn Hazm in Al-Muhalla. Ibn Hazm said it is a fabricated disapproved hadith.
One of the things that support the opinion that allows menstruating women and anyone who is in state of janabah inside the mosque is the fact that non-Muslims are allowed to enter in the first place.
During the lifetime of Prophet Muhammad (peace be upon him), non-Muslims used to frequently enter the mosque either to embrace Islam, convey a message (to the Prophet), or for the purpose of discussion and arguments, as it happened with the Christian delegation of Najran who stayed and set their tents in a corner of the Prophet’s mosque for days. Likewise, the Christians of Abyssinia used to perform inside the mosque of God’s Messenger with their spears in the presence of the Prophet and his Companions.
Since non-Muslims are allowed to enter the mosque in the first place, so it is more appropriate for Muslim menstruating women and those in state of janabah to enter the mosque to attend classes, study and teach Qur’an.
And if it is permissible for the menstruating women and the junub to pass by the mosque for a certain need such as sleeping, seeking shelter from heat or getting some rest, so it is more appropriate for them to enter with the purpose of seeking and teaching knowledge.
If some would claim that the reason behind forbidding a menstruating woman from entering the mosque is the fear of causing impurity to the mosque where people perform their prayers through leaking blood, it is clear that women in our time are using safer means for their personal hygiene. Moreover, it is permissible for a woman during istihadah—i.e. bleeding outside regular menses—to fast, pray and attend religious gatherings.
Lady Aishah (may God be pleased with her) narrated, “One of the wives of Prophet Muhammad (peace be upon him) practiced itikaf (spiritual retreat) with him while she had bleeding in between her periods (istihadah). She would see red (blood) and sometimes we put a tray beneath her when she offered the prayer” (Al-Bukhari).
If the reason behind forbidding a menstruating woman from entering the mosque is fear of leaking blood, it thus takes the same ruling as the case of istihadah. If women were permitted to enter the Prophet’s mosque during his lifetime, it is illogical for us to ask our women to refrain from our mosques especially with the new means available for women to keep their personal hygiene intact. Also women in our time are in need more than ever of religious knowledge by means of attending gatherings of knowledge and circles which exhort God the Almighty.
In another hadith, the Prophet clarified that the reason for allowing all women to go out and attend the Eid prayer is to be part of the blessings and goodness of the day of Eid, to make remembrance of God and to learn. So, women are invited to attend Eid prayer to learn from the sermon, benefit from the Imam and supplicate to God with other Muslims and the like. This is typically what classes in mosques offer.
Based on the above and in reference to the question, there is no impermissibility in the Shari`ah for menstruating women along with anyone in a state of janabah from entering the mosque, to pass by it or to attend classes and the like. However, a woman, either menstruating, postpartum or in istihadah, must use the proper women’s hygienic materials to prevent contaminating the mosque. It is also recommended if space is limited to leave the mosque at the time of prayers to give space to other women to perform prayers
Almighty Allah knows best.