Sheikh Ahmad Kutty, a senior lecturer and Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada , states: “Every Muslim knows that they are not allowed to rub shoulders with members of the opposite sex while praying or at other times. Hajj crowds are unavoidable, so certain things tolerated there cannot be recommended in ordinary circumstances.
In ordinary circumstances, men and women are not supposed to stand close to one another in prayer. The Prophet (peace and blessings be upon him) always maintained some distance/gap between the line of men and women in Prayer. The Prophet (peace and blessings be upon him) also ordered us, “Pray as you have seen me praying.” So we are to comply with his order.”