The majority of scholars, including the four Imams, say it is not permissible for a menstruating woman to enter or stay in a mosque.
Evidence includes:
- Qur’an [An-Nisa’ 4:43]: “Do not approach prayer while intoxicated or in a state of Janabah except passing through, until you have washed.” Scholars analogize (Qiyas) menstruation to Janabah regarding entering prayer places.
- Hadith of Umm ‘Atiyyah (Radi Allahu Anha): The Prophet (Salla Allahu 'Alayhi Wa Sallam) told menstruating women to stay away from the prayer-place of the Muslims during Eid. (Bukhari & Muslim).
This indicates they may attend the gathering but cannot stay in the prayer area.
Another narration: The Prophet told Aishah to hand him a mat from the mosque. She said: “I am menstruating,” and he replied: “Your menstruation is not in your hand.” This shows she knew not to enter the mosque fully, but merely extending her arm does not count as entering.
Based on these evidences:
- A menstruating woman should not remain inside a mosque or designated prayer area.
- For Eid, she may stay in a nearby place where she can hear the khutbah, make dhikr, and make dua.
- Passing through the mosque briefly (without staying) is permissible when needed.
The prohibition is specifically about staying in the mosque, not brief transit.
The same ayah applies directly, rather than by analogy, to a person in Janabah; see entering or staying in a mosque during Janabah for how it is read in that case and what a genuine need allows there.
The same restriction, for the same reason, applies to a woman in nifas; see can a woman in nifas enter or stay in a mosque for how it plays out across her forty or sixty days and what still reaches her while it lasts.
The same principle is what keeps a menstruating woman out of the Masjid al-Haram for tawaf during Hajj or Umrah; see what if your period starts during Hajj for how the rest of the pilgrimage is unaffected by it. For a period beginning during an Umrah trip specifically, what if your period starts during Umrah covers exactly what waits outside the mosque and what does not.
Istihadah is a different case entirely: it does not close the mosque to her at all. See can a woman with istihadah enter or stay in a mosque for the hadith of a Companion who performed i'tikaf, dwelling inside the mosque, while she had istihadah.
The same restriction is why hayd interrupts an ongoing i'tikaf outright, since i'tikaf has no existence apart from the mosque to fall back on; see what if your period starts during i'tikaf for what that means for the days already spent there.