Ruling on men praying behind woman when there is a need to do that
Question

What is the ruling on men praying behind woman or in rows alongside their rows?
Praise be to Allah.What is prescribed is for the men to be in front of the woman, and for the woman to be behind the men in the mosque. Wherever the women pray behind the men, this is what is prescribed and is what is obligatory. But in cases of necessity, such as during the days of Hajj and during Hajj season, in al-Masjid an-Nabawi and in al-Masjid al-Haram, where women may be standing to the right or left of men, or in front of them, that does not affect the prayer of the men, so the men’s prayer is valid, even if the women are in front of them or on the left or on the right. As for what is Sunnah and what is prescribed and obligatory, the woman should be behind the men.
Shaykh ‘Abd al-‘Aziz ibn Baz (may Allah have mercy on him).
Fatawa Nur ‘ala ad-Darb (2/919).