A 17-year-old girl who started a £300,000 school fire in a Suffolk village has avoided being locked up.

The teenager, who cannot be named for legal reasons, had been drinking heavily when she ignited plastic cups in a storage shed before flames spread to the main building at Exning Primary School, near Newmarket.

Firefighters battled to save the Victorian building in Oxford Street during the early hours of September 4 last year but were unable to prevent extensive damage being caused.

CCTV pictures showed the teenager and another girl entering the school grounds and emerging shortly afterwards and looking back towards the school as the blaze took hold before running off, prosecutor Laura Kenyon told Ipswich Crown Court.

One classroom was gutted and other parts of the school affected by smoke and water. Five thousand library books were destroyed together with IT equipment, children’s work and other material.

Ms Kenyon said that neighbours reported seeing flames leaping as high as the roof before the blaze was brought under control.

Fire investigators established that the blaze had started in a storage shed adjacent to the main building and was deliberate.

Ms Kenyon said both girls seen on CCTV attended hospital the following day after self-harming incidents and the 17-year-old had said that the fire had been her fault and had been her “biggest mistake.”

The court heard that a cigarette light had been used to ignite plastic cups being stored in the shed, which was destroyed in the outbreak.

Ms Kenyon said no evidence was being offered against the second girl after the 17-year-old accepted full responsibility for what happened.

Head teacher James Clarke said in a statement that the impact of the fire on the 200 pupil school had been “huge.”

Mr Clarke said: “The fact that it was being treated as arson made us feel sick.”

For some pupils, their first day at school had to be postponed, while the parents of others had reported their children being unable to sleep and having nightmares.

Defending, Joanne Eley said the girl who had admitted a charge of arson, suffered from mental health issues and had consumed a “significant” amount of vodka.

Miss Eley said: “She tells me that if she had been sober she wouldn’t have done this.”

The girl had only “patchy” memories of what had taken place, said Miss Eley, who told the court: “The plan that evening wasn’t, it seems, to go out and start a fire. It was to go out and meet some older boys and get some cigarettes which is why she had the lighter with her.”

Since the incident the girl had made a serious attempt to end her own life against a background of mental health issues and family problems, said Miss Eley.

Miss Eley said: “She is a young lady who has a very fragile mental health and is seen regularly by the mental health services.”

Sentencing her, Judge David Goodin told the girl: “I’m not going to send you into custody today. In many ways you richly deserve it.”

Judge Goodin said he had been “narrowly persuaded” that the negative effects of the girl being sent to a Young Offenders Institution would outweigh the benefits.

The judge told the girl: “I hope you will in your own best interests wake up every morning and think ‘my goodness, I could be in prison today’.

“Do that in your own interests because that might be a good way of deterring you from anything like this again.”

The girl was made the subject of a three year Youth Rehabilitation Order with conditions to be under Probation Service supervision and complete 60 hours of unpaid community work.

A 9pm to 7am curfew was also imposed on the girl for the next three months. Judge Goodin told her: “You are at the last ditch. This is your last chance, a real opportunity to turn your life around - do it.”