A judge said that it was a miracle nobody was killed when a car driven dangerously through the Cotswolds, ended up on its roof after narrowly avoiding a crash with a teenage learner driver.

Patrick Williams, 33, pleaded guilty at Gloucester Crown Court on Monday to driving dangerously on the A433 near Culkerton on April 2, failing to provide a specimen for analysis and driving without a valid licence or insurance.

The judge, Recorder Sarah Regan, said “It is a miracle that nobody was killed or seriously hurt.”

She also praised the father of a 17-year-old learner driver who acted quickly by grabbing the steering wheel to avoid a head-on crash.

Prosecutor James Haskell said: “One witness saw the vehicle approach a right hand band and witnessed a big explosion when a blue car hit the embankment, causing it to overturn and slide down the road on its roof.

“The witness said he could smell alcohol on the driver and believed he was drunk.

“The incident was also witnessed by a family who were out with their 17-year-old son, who was learning to drive. The father described how his son rounded a bend and they saw a car on the wrong side of the road as it mounted the grass verge and then collided with a wall before coming straight at them.

“He states he grabbed at the steering wheel, ensuring the out of control vehicle did not collide with them head on and only causing damage to the side of their car."

The court heard that Williams, of Robin Gardens, Cheselbourne, Dorset told the father that he been beaten up at the barbecue in Wotton-under-Edge, and began to get agitated when photographs of the scene were being taken.

When the police arrived Williams refused to take a roadside breath or drug test and continued to behave aggressively.

Police confirmed that earlier that day they had received reports of a disturbance in the London Road area of Wotton-under-Edge at 6.10pm in which damage had been done to a blue Peugeot with an iron bar. There was no barbecue or any disorder reported in the area.

Mr Haskell stated that when Williams was taken into custody, he refused to give a sample of his blood for analysis. He then said he had been to a barbecue in Yate and was with his partner, who owned the vehicle.

“His partner was questioned by police. She believed that her vehicle was still in Dorset and said she hadn’t been with him all day,” Mr Haskell said.

The police retraced Williams’ journey, which they believe was just over 12 miles and that he had been driving aggressively for some distance.

In a witness statement the family who narrowly avoided a collision with Williams said the incident has had a financial impact on their son who was learning to drive. The father stated that he broke down in tears when he realised that his whole family could have been wiped out in an instant.

Rodney Wilson, defending, said: “Williams does appreciate the seriousness of what could have happened, but he needs to be sentenced for what he did and not what could have happened.

“I question that he was driving aggressively throughout. As well as causing potential death or serious injury to innocent people, it is also through luck more than judgement that he didn’t kill or cause serious injury to himself.

“Williams is remorseful and has not been in trouble with the courts or the police since this incident, which shows there is a real prospect of rehabilitation.”

The judge, Recorder Sarah Regan told Williams: “In the words of one witness, you were driving like a lunatic.

She sentenced him to a nine month prison term, suspended for 12 months and added: “The victim’s family will have to live with the memory of your driving for the rest of their lives.”

The judge also ordered that Williams pay the young driver £1,000 compensation, attend 10 rehabilitation activity requirement days and complete 45 hours of unpaid work and attend court for monthly judicial reviews.

Williams was banned from driving for 18 months and ordered to take an extensive retest.