Aslef's lawyer had argued it was about the union's "fundamental right to pursue its industrial action".

Nick Brown, GTR's chief operating officer, said:

Naturally we are disappointed. The judge said that such unprecedented strike action by Aslef would cause massive disruption to the public.

The judge also said the widespread use of trains using driver operation is perfectly safe both in Southern and elsewhere in the UK.

We brought this action for the benefit of our passengers. The judge has given us permission to go to the Court of Appeal which we will now consider with our legal team.

Mick Whelan, general secretary of Aslef, said Southern had "wasted shareholders' money, passengers' money and taxpayers' money" on a case "it was always going to lose".

"Now the company should do the right thing and sit down with us and negotiate – properly, sensibly and in good faith – to do a deal for the benefit of passengers, staff and, yes, the company," he added. "Just like ScotRail did with us earlier this year."

Ahead of the decision, Charles Horton, chief executive of GTR, had said legal action was taken as a necessity: "Obviously we would prefer to resolve this directly with Aslef. We asked the union to withdraw the industrial action and to re-enter discussions but they refused to do so, which means that we now have no choice but to go to court."

He said: "Passengers now face the prospect of 40 days of continuous industrial action by Aslef, and, on top of months of travel misery they've already suffered, it is totally unacceptable."

Naomi Horton, a rail partner at law firm Ashurst, said the operator had relied on "a novel approach, relying on a European case which established that strikes should not unjustifiably infringe the fundamental right to move freely around the EU and placed emphasis on the disruption to their services to Gatwick Airport".