Praise be to Allah.
Islamic teaching does not allow a woman to pray or enter the mosque when she is menstruating, as has been explained previously in fatwas no. 33649 and 146758.
With regard to a woman who is pregnant, Islamic teaching does not forbid her to pray or enter the mosque. So she is obliged to offer the five daily prayers, and she may offer whatever supererogatory prayers she wants. It is permissible for her to enter the mosque to pray or to attend lessons and lectures and beneficial gatherings, so long as she adheres to the conditions set out in Islamic teaching for a Muslim woman to go out to the mosque, which have been explained previously in fatwa no. 49898.
There are Islamic rulings which Allah, may He be exalted, has prescribed for the pregnant woman, that are appropriate to her situation. We will mention some of these rulings here. They include the following:
It is prohibited for her to eat or drink anything or to do anything that will harm the foetus or lead to miscarriage. For more information, please see fatwas no. 13319 and 146158.
It is permissible for a pregnant woman to break the fast in Ramadan if fasting is too difficult for her. The ruling may reach the degree of it being prohibited for her to fast if doing so will harm the foetus.
It says in al-Mawsoo‘ah al-Fiqhiyyah (16/271):
It is permissible for the pregnant woman to break the fast if she fears or thinks it most likely that she or her child will be harmed, and she must break the fast if she fears that she may die or be greatly harmed, and she has to make up the fasts, without paying any fidyah (penalty). This is according to the consensus of the fuqaha’ (jurists). They are also unanimously agreed that a pregnant woman does not have to pay the fidyah if she breaks the fast for fear of harm to herself, because she is in the same situation as a sick person who fears harm to himself. End quote.
And Allah knows best.