Can women pray next to men with a barrier?
If a woman prays alongside a man but there is a barrier between them, such as a wall, or a gap which is wide enough for a person to stand and pray there, then the prayer is valid according to the majority of scholars among the Hanafis, Malikis, Shafi’is and Hanbalis.
However, they differed with regard to a woman who prays beside a man with nothing separating them . The Hanafis are of the view that she invalidates the prayer of three men: one to her right, another to her left and a third behind her, subject to conditions that they mentioned, which may be summed up by saying that if the woman is desirable,
has reached the age of seven years or is of marriageable age, with some variations in the madhhab on this point, and she joins in a regular prayer with a man, which includes bowing and prostrating, and they join together simultaneously in the opening takbir and the prayer, and the imam intended to lead women in prayer, and other details which may be referred to in their books. (See al-Mabsut (1/183); Bada’i` As-Sana’i` (1/239); Tabyin Al-Haqa’iq (1/136-139)
An-Nawawi (may Allah have mercy on him) said, discussing the difference of opinion on this topic and summing up the Hanafi view:
“If a man prays and there is a woman beside him, that does not invalidate his prayer or hers, whether he is leading the prayer or praying behind an imam. This is our view and it was also the view of Malik and the majority. Abu Hanifah said: If the woman is not praying or she is offering a different prayer than him and is not praying with him, his prayer and hers are both valid. If she is praying with him – and in Abu Hanifah’s view she cannot be praying with him unless
the imam intended to lead the women in prayer too – then if she joins the prayer and stands beside a man, the prayer of the men who are standing on either side of her is invalidated, but her prayer and the prayer of the man who is beside the man who is beside her are not invalidated, because there is a barrier between her and him. If she is in the row in front of him, the prayer of those who are beside her and behind her are invalidated, but the prayer of those who are beside
the ones who are beside her is not invalidated, because there is a barrier between them. If the women’s row is behind the imam and there is a row of men behind them, then the prayer of the row behind them is invalidated, but by analogy the prayer of the rows behind that row is not invalidated, because there is a barrier. But we say that the prayer
of the rows of men behind them is invalidated, even if there are a hundred rows. If she stands beside the imam, then the prayer of the imam is invalidated, because she is next to him, and his view is that if the prayer of the imam is invalidated, the prayer of those who are praying behind him is also invalidated, and her prayer is also invalidated, because she is one of those who are praying behind him.
This view is based on weak evidence and this argument has no basis. Our view is that the prayer is valid unless there is sound Shar`i evidence to prove that it is invalid, and they do not have such proof. Our companions drew an analogy from her standing in the funeral prayer, which is not invalidated in their view. Allah knows best which is correct, and to Him be all praise. He is the Source of strength, guidance and protection.” (Al-Majmu` (3/331)
But if there is a barrier, the Hanafis agree with the majority that it does not invalidate the prayer of either of them, as it says in Tabyin Al-Haqa’iq (1/138)