A 16-year-old boy who constructed a shrapnel-filled device which could have been made into a viable CO2 bomb has been detained for five years.

Kieran Cleary, of Holme Wood, told friends he was going to "go on a rampage" and "kill many people" weeks after making the potential weapon, prosecutors said.

A trial at Leeds Crown Court also heard the teen warned fellow pupils around a year earlier that he was going to carry out a school shooting and he praised Adolf Hitler, telling friends: "Gas the Jews."

A judge said Cleary told classmates: "I may as well bring a gun into school and do a school shooting."

The teenager, who had access to the Dark Web, had been extensively researching bomb-making tactics online, and nearly created a weapon with a potential 30-metre blast radius capable of being used "to cause maximum harm and death to civilians", prosecutors said.

His internet searches reflected a desire to seek out "extreme right-wing material and anti-Muslim material", the court was told.

Following a trial earlier this year, Cleary was convicted of making an explosive substance and three counts of possession of a document likely to be useful to a person committing or preparing an act of terrorism, but jurors cleared him of the more serious offence of making an explosive substance with intent.

Sentencing him on Friday to five years in custody, Judge Geoffrey Marson QC said: "By its verdict, the jury were satisfied that you intended to complete the bomb and create a viable explosive device.

"There was a great potential for harm, even if there was no intention to use it."

The boy, with a long fringe and wearing a T-shirt, showed no reaction as he was told the length of his sentence, which includes a four-year licence period.

During the trial, prosecutors said that, with the addition of gunpowder and a fuse, the device could have been a credible threat.

Paul Greaney QC, prosecuting, said the defendant became interested in far-right ideology, using the internet to access videos and information about murder, torture and mutilation.

He first came to the attention of police aged 13 and was referred to Prevent, the Government's counter-terrorism strategy, in 2017, the court heard.

In July 2018, Prevent received information that the boy had told fellow pupils he was going to go on a rampage, aiming to kill many people and then be shot by the police or kill himself, and this led to a search of his home in Bradford, where items were found including two carbon dioxide canisters joined together and an assortment of nails, tacks and panel pins.

One of the canisters had been filled with nails.

The court heard that he searched for and watched videos about the English Defence League, attacks on Muslims, the Columbine High School massacre, and murder and mutilation.

The judge said: "Whilst you do not appear to hold any particular ideology, you are markedly desensitised to such difficult material.

"The evidence shows that you are prone to violence and harbour dark and homicidal thoughts.

"It is unclear whether you were motivated by any extremist ideology - you were simply showing off."

Psychological examination has shown the boy's personality traits reflect a potential risk to himself and to others, a lack of empathy, manipulation of others and an obsession with weapons, Mr Greaney said.

Even after being detained, the boy accessed the internet to make "far-right protestations" using the username White Terrorist, the court heard

Giving evidence in his defence during the trial, the boy said he made extreme comments because he was showing off and "being stupid", and that he had only built the device to show off to his friends.

Ali Naseem Bajwa QC, defending, said the jury's verdict reflected the lack of "malevolent intent with regard to the explosive device", which he said was stored in open sight in the teenager's bedroom in Camberley Mount, Holme Wood, Bradford.

Detective Chief Superintendent Martin Snowden, from Counter Terrorism Policing North East, said: "This is a disturbing case of a teenager who developed an alarming interest in extremist ideology, violence, firearms and explosives.

"Despite extensive attempts to steer this boy away from the path of criminality, due to the progression of his behaviour, he was arrested and charged with serious offences.

"His online searches, combined with the manufacture of an explosive device, had the potential to put the safety of others at risk and could not go unprosecuted."

The Crown Prosecution Service said the boy had been searching the terms "how to get over first kill jitters" and "why do I think about killing others" online.