A student nearly caused several accidents while being chased by police in Malmesbury after he bought cannabis to celebrate his last exam.

A pedestrian had to leap out of the way and other cars had to take evasive action before the 17-year-old eventually pulled over, Chippenham magistrates were told at a youth court.

The teenager, who cannot be named because he is under 18, admitted dangerous driving, possession of cannabis and failing to stop for police. He was put on a nine-month referral order, banned from driving for a year and ordered to pay £85 costs.

Prosecutor Vyvyan Thatcher said officers saw the VW car just before 1pm on January 25 and decided to stop it. After they switched on their blue lights they saw the driver look in the mirror and then accelerate away.

Speeds of up to 60mph were recorded during the incident.

In Bremilham Road a pedestrian was crossing as the car approached and had to jump to avoid it.

Another driver had to take violent evasive action on the Gloucester Road roundabout and a short while later an oncoming car had to mount the kerb to avoid a collision when the teen drove on the wrong side of the road.

Kim Brereton, defending, said the youth, who was studying for A-levels and expects to achieve good grades, had never had any reprimands or warnings and had never been in court before. He had been on his way to take his last exam of the term and had bought the cannabis to celebrate afterwards.

She said: “He decided to try and get away when he saw the police turn around.”

The teenager said: “For ten minutes of stupidity I’m going to suffer for the next year of my life.”

He told the bench he had panicked and been worried about his mother finding out.

Chairman of the bench Michael Lightfield told the youth he had been lucky.

“You could have caused at least two accidents in that mad escapade,” he said.

The youngster’s mother, who was in court, said: “I am still shocked it has happened.

“I think he is very lucky that something worse did not happen and I’m so grateful that it did not.”