All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
This matter is not determined by the sharee'ah with a specific distance – as far as we know – and such matters depend on the customs and on the achievement of the purpose of the prohibition of the forbidden mixing between men and women; which is to be safe from temptation. So a woman should stay distant from a man in such a way that she does not touch him, nor has physical contact with him, and nothing can lead to temptation.
Shaykh Ibn Baaz said in his Fataawa, “The women used to be forbidden from walking in the middle of the street, and they were ordered to walk on the sides of the street as a way of being careful from coming into physical contact with men and thereby causing temptation by them touching each other when walking in the street...”
The hadeeth to which he referred was reported by Abu Dawood from Abu Usyad Al-Ansaari who heard the Prophet while he was coming outside the mosque and men mixed with the women in the street, say to the women, “Draw back, for you (women) must not walk in the middle of the road; keep to the sides of the road.” Then the women walked so close to the walls that their garments rubbed against them.
We should point out that the presence of two or three non-mahram men with a woman is permissible if there is no fear of temptation, such as if these men are religious and upright, as well as the woman.
The commentary of Al-Jamal, in the Shaafi'i School of jurisprudence, reads, “...as regards the seclusion of men with a woman, if according to the custom it is impossible for them to agree to commit an immoral act with her, then this is a permissible seclusion, otherwise no [otherwise such seclusion is not permissible].”
The evidence about this is the hadeeth reported by Al-Bukhari and Muslim, in which it is related that the Prophet said, “A man should not enter after this present day upon a woman whose husband is absent unless there is a man or two along with him.” An-Nawawi while interpreting this hadeeth, said, “The apparent meaning of this hadeeth is that it is permissible for two or three men to be in seclusion with a woman. However, the well-known opinion in our School is that it is forbidden, so the hadeeth is interpreted to apply to a group for whom it is impossible to agree to commit an immoral act with her due to their righteousness and chivalry, and so forth.”
Allaah knows best.