A high-speed passenger train avoided a fatal crash by millimetres after an old ambulance was driven through level crossing barriers on to the track, Bradford Crown Court heard.

The hair-raising near-miss followed a 37 mile pursuit along the A65 at up to 92mph, involving several patrol cars and the police helicopter.

Shane Hughes, 41, who sped away from the scene of a fatal crash in a decommissioned ambulance, with the blue lights flashing, was responsible for the worst piece of dangerous driving the judge had ever seen.

He narrowly missed oncoming vehicles, drove on the wrong side of the road and went the wrong way round a roundabout in the pursuit from Ingleton to the railway crossing at Kildwick on Friday, July 13.

The lives of road users, police officers and passengers on the 70mph train were put at risk and it was a miracle no one was killed, Judge Jonathan Rose told Hughes.

Hughes, of Ramsgate Street, Halifax, was today jailed for a total of 22 months after pleading guilty to dangerous driving, obstructing the railway line, driving while disqualified and without insurance and failing to provide a specimen for analysis.

Prosecutor Alisha Kaye said that Hughes was a banned driver with seven previous convictions for driving while disqualified when he sped away from the scene of the accident on the A65 near Clapham.

He was at the wheel of a decommissioned ambulance when he was chased by the police and tracked by the force helicopter through the villages of Giggleswick, Long Preston and Hellifield.

Miss Kaye said officers had to drive at 92mph just to keep up with him.

At the Kildwick crossing, he crashed through the barrier as it was coming down and the lights were flashing. He got stuck on the track and seconds later, a train came through, missing the crashed ambulance by millimetres.

Footage from the train cab showed how close it came to hitting the ambulance.

Hughes fled on foot and was apprehended in a garden in Airedale View. He pretended to be a police officer to try to persuade the householder to hand over his car keys.

Hughes tested positive for cannabis after his arrest.

He gave a “no comment” police interview and told officers they should have called off the pursuit.

Hughes’ barrister, Stephen Wood, conceded: “A catastrophe was avoided by centimetres,” after Hughes ended up on the railway track.

“It was quite dreadful driving,” Mr Wood said.

But the maximum sentence for both dangerous driving and obstructing the railway line was two years imprisonment and Hughes had by law to be given a full third off for his early guilty pleas.

Mr Wood said that pre-sentence and psychological reports revealed the horrible events of Hughes’ childhood.

“He has very real demons that play in his mind over and over again,” Mr Wood said.

Hughes was suffering from post-traumatic stress disorder and substance misuse had blighted his life.

Hughes buried his face in his hands as footage of the police pursuit and the near-miss on the railway line were played in court.

Judge Jonathan Rose said it was the worst case of dangerous driving he had seen in all his years at the Bar.

“You drove over 37 miles in an utterly disgraceful and appalling manner,” he told Hughes.

It was nothing short of a miracle that no one had been killed.

“The train was inches from disaster and had it been on the other track, death would have followed,” the judge said.

He banned Hughes from driving for six years and 11 months.

Traffic Constable Gemma Brett, of the Major Collision Investigation Unit who led the case for North Yorkshire Police, said: “On the day of these offences, Shane Hughes put numerous lives at risk and could have caused untold carnage.

“His actions were totally irresponsible, illegal and focused entirely on himself with no thought whatsoever for the safety of anyone else.

“The sentence handed to him today shows that the courts, as well as the police, are determined to keep North Yorkshire’s communities safe by getting offenders like Hughes off our roads.”