Volume 4, Book 52, Number 250 :
Narrated by Ibn Abbas (radiallaahu `anhu)
That he heard the Prophet (sallallaahu `alayhi wasallam) saying, “It is not permissible for a man to be alone with a woman, and no lady should travel except with a Mahram (i.e. her husband or a person whom she cannot marry in any case for ever; e.g. her father, brother, etc.).” Then a man got up and said, “O Allah’s Apostle! I have enlisted in the army for such-and-such Ghazwa and my wife is proceeding for Hajj.” Allah’s Apostle (sallallaahu `alayhi wasallam) said, “Go, and perform the Hajj with your wife.”
It is not permissible for a man to be alone with a woman who is not his mahram, because the Prophet (blessings and peace of Allah be upon him) said: “No man should be alone with a woman unless there is a mahram with them.” Narrated by al-Bukhaari (1862) and Muslim (1341). And he (blessings and peace of Allah be upon him) said: “No man is alone with a woman but the Shaytaan is the third one present.” Narrated by al-Tirmidhi (1171) and classed as saheeh by al-Albaani in Saheeh al-Tirmidhi.
Al-Nawawi (may Allah have mercy on him) narrated in Sharh Muslim (14/153) that there was consensus among the scholars that it is haraam for a man to be alone with a woman who is not his mahram. This was narrated by al-Haafiz in al-Fath (4/77).
“Being alone with” (khalwah) refers to when the man and woman are in a place where no one can see them.
The scholars of the Standing Committee for Issuing Fatwas were asked: Does khalwah (“being alone with”) refer to when a man is alone with a woman in some house, far away from the eyes of people, or does it refer to any situation in which a man is alone with a woman, even if they can be seen by others?
They replied: What is meant by the “being alone with” (khalwah) that is forbidden in sharee‘ah is not only when a man is alone with a woman who is not his mahram in a place where they cannot be seen; rather it also includes situations in which he is alone with her in a place where she can converse with him and he can converse with her, even if they can be seen by other people, but their words cannot be heard, whether that is out in the open or in a car or on the roof of a house, and so on. That is because khalwah has been forbidden because it is the harbinger of zina and the means that leads to it. So everything that could lead to that, even making an arrangement to do that later, comes under the ruling of physical khalwah or being alone in a place where they cannot be seen. End quote.
Shaykh ‘Abd al-‘Azeez ibn ‘Abd-Allah ibn Baaz; Shaykh ‘Abd al-Razzaaq ‘Afeefi; Shaykh ‘Abd-Allah ibn Ghadyaan; Shaykh ‘Abd-Allah ibn Qa ‘ood
Fataawa al-Lajnah al-Daa’imah, 17/57
Khalwah can be avoided with the presence of a mahram or the presence of a righteous woman, according to the correct opinion.
It says in Asna’l-Mataalib (3/407): It is permissible for a man to be alone with two women, but not the opposite; i.e., it is not permissible for two non-mahram men to be alone with a woman even if it is unlikely that they would agree to commit immoral actions, as was clearly stated by al-Nawawi in al-Majmoo‘; that is because a woman feels more shy of another woman than a man feels shy of another man.