For men to mix with women on public transport, at work or in school is haraam, because it leads to great evils as is obvious. The evidence that mixing is haraam has been discussed in the answer to question no. 1200.
If a person has no other choice but to travel on mixed public transport, then he must fear Allaah as much as he can, lower his gaze and not look at haraam things, and avoid sitting beside women as much as he can, even if that means standing, seeking thereby to please Allaah and avoid the fitnah that the Prophet (peace and blessings of Allaah be upon him) warned against: “Beware of women, for the first fitnah among the Children of Israel was because of women.” Narrated by Muslim (2742).
And he said: “I have not left behind me any fitnah more harmful to men than women.” Narrated by al-Bukhaari (5096)and Muslim (2742).
A person can avoid this by changing his seat and so on.
“And whosoever fears Allaah and keeps his duty to Him, He will make a way for him to get out (from every difficulty).
3. And He will provide him from (sources) he never could imagine. And whosoever puts his trust in Allaah, then He will suffice him. Verily, Allaah will accomplish his purpose. Indeed Allaah has set a measure for all things”
If a person has no choice but to use public transit and he cannot change his place or change vehicles, and he cannot stand because that is even more crowded and brings even more contact with women, then there is no sin on him in that case if he sits next to a woman, so long as he keeps away from her as much as possible.
If he fears fitnah for himself and the shaytaan starts to whisper to him and divert his thoughts, then he must get off as soon as he can, no matter how late that may make him for work or school, because there is nothing more precious to a man than his religious commitment, so he must protect it.
We asked Shaykh Ibn Jibreen about the ruling on sitting next to a woman on public transport, and he said that it is permissible as much as it is necessary, if there is no fear of temptation.
And Allaah knows best.