A teenage Isis supporter who was arrested hours before launching a planned terror attack in Cardiff has been jailed for life.

Lloyd Gunton, 17, declared himself a “soldier of the Islamic State” in a note intended to be read after he rammed a car into victims in the Welsh capital, before massacring as many people as possible with a knife and hammer.

He had researched a Justin Bieber concert to be held that night, which was among potential targets including the Castle Quarter, New Theatre, Capitol shopping centre and Central Library.

Birmingham Crown Court heard the Welsh teenager was autistic and had been heavily influenced by the Isis propaganda he consumed online.

Judge Mark Wall QC handed him an indeterminate life sentence with a minimum of 11 years, which would have been higher if not for his autism, age and previous good character.

“I sentence you on the basis that at the time of your arrest you were within hours of committing an act of atrocity on the streets of Cardiff”, the judge said.

“You were committed to carrying out the attack throughout a protracted period, a commitment best demonstrated by your martyrdom letter and open support for Isis on Instagram.

The defendant had made several internet searches relating to a Justin Bieber concert in Cardiff in the days leading up to his arrest (Getty)

“You were dedicated to the cause for approximately one year: this was no passing phase … You are at high risk of re-offending and if you do, you pose a high risk of causing the public serious harm.”

Justice Wall said that autism had made Gunton “something of a loner and someone more easily impressed by the things you read on the internet”.

“Yours is not a condition from which you will recover”, he added.

“It is important that, having been tempted to commit a serious offence such as this, you are under some form of supervision for the rest of your life.”

Gunton, who had a provisional driving licence, planned to steal a vehicle and drive it into a crowd of “non-believers” before inflicting as much damage as possible with a knife and hammer before being killed by police.

The plot repeats those carried out in Westminster and London Bridge and follows instructions sent out by Isis in online propaganda magazines translated into multiple languages and distributed around the world, which have advised fanatics on what vehicles and weapons to use to maximise bloodshed.

The terrorist group has been intensifying calls for lone-wolf terror attacks since huge territorial losses and security crackdowns made it harder for supporters to journey to Syria and Iraq to fight.

Security services have warned that “remote radicalisation” online has made plots quicker to develop and harder to detect, with would-be attackers like Gunton drawing up their plans without ever meeting another extremist in person.

Justice Wall said it was impossible to estimate how many people could have been killed but said Gunton’s intent was “mass murder” with a total disregard for human life.

Police found a rucksack in the A-level student’s bedroom that contained a knife, a hammer and martyrdom letter proclaiming his intentions.

Gunton was arrested weeks after the London Bridge terror attack (PA)

“I am a soldier of the Islamic State and I have attacked Cardiff today because your Government keep [sic] on bombing targets in Syria and Iraq,” said the handwritten note. “There will be more attacks in the future.”

It featured bullet points including “run down the non-believers with a car” and “strike the infidels, who oppose Allah, in the neck” and ended with the words: “In the name of Allah, may terrorism greet your country. May there be more bomb and vehicle attacks with Allah’s permission.”

Gunton claimed he had spoken to a man on Instagram who “told him he needed to commit a terrorist act if he wanted to go to paradise”.

The boy had downloaded two editions of an Isis propaganda magazine containing detailed instructions on stabbing attacks, including what knife to use, where to stab someone to cause the most harm, and how to carry out vehicle massacres.

His Instagram password was “truck attack”, with the account including photos of terrorists, the black flag used by Isis and posts encouraging a terrorist attack in Cardiff.

“Cardiff, are you ready for our terror,” one asked, while a promotional poster for Justin Bieber’s concert at the Principality Stadium on 30 June was found on his computer, alongside a search for information the event and its security.

The court heard that Gunton’s interest in violent extremism dated back to summer 2016, with his internet history including searches for “Isis beheading video”, “Isis terrorist attacks”, “police car UK armed response”, “how to create a terror attack”, “driving a lorry into a crowd of people” and “what does getting shot feel like”.

He had also looked up information on the murder of Fusilier Lee Rigby, carried out by two Islamist extremists linked to Anjem Choudary, and the Isis-linked lorry attacks in Nice and Berlin.

Gunton denied intending to harm anyone but was convicted of preparing an act of terrorism and encouraging terrorism after being arrested in June 2017.

UK news in pictures Show all 50 1 /50 UK news in pictures UK news in pictures 18 September 2020 A model presents a creation during the Bora Aksu catwalk show at London Fashion Week 2020 Reuters UK news in pictures 17 September 2020 World kickboxing champion Carl Thomas during his attempt to run a marathon while pulling a plane at Elvington Airfield near York. The attempt is raising funds for Ollie's Army Battling Against Battens, an organisation campaigning to raise GBP 250,000 to fund a clinical trial aimed at saving the sight of children with CNL2 Batten Disease PA UK news in pictures 16 September 2020 Labour deputy leader Angela Rayner speaking during Prime Minister's Questions UK Parliament/AFP/Getty UK news in pictures 15 September 2020 People enjoying the autumn sunshine as they punt along the River Cam in Cambridge PA UK news in pictures 14 September 2020 Early morning light bathes the skyscrapers of the City of London, at the start of a week in which the UK is expected to bask in temperatures of more than 30 degrees PA UK news in pictures 13 September 2020 England celebrate after they dismissed Australia's Alex Carey to win the second ODI match of the series at Emirates Old Trafford, Manchester PA UK news in pictures 12 September 2020 Protesters outside BBC Broadcasting House in central London, as marches and rallies form across the country calling for a 15% pay rise for NHS workers and an increase in NHS funding PA UK news in pictures 11 September 2020 An empty migrant dinghy floats off the beach at St Margaret's Bay after the occupants landed from France in Dover Getty UK news in pictures 10 September 2020 A view of small boats thought to be used in migrant crossings across the Channel at a storage facility in Dover, Kent PA UK news in pictures 9 September 2020 EU's chief negotiator Michel Barnier, left, arriving from the Eurostar with EU Ambassador to the UK, Portuguese diplomat Joao Vale de Almeida at St Pancras International railway station, London, for the latest round of the negotiations on a free trade deal between the EU and the UK PA UK news in pictures 8 September 2020 Dawn over Coquet Island, a small island off Amble on the Northumberland coast PA UK news in pictures 7 September 2020 A hovercraft arrives to Southsea, Hampshire from the Isle of Wight PA UK news in pictures 6 September 2020 Forensics officers near the scene of multiple reported stabbings in Birmingham Reuters UK news in pictures 5 September 2020 Anti-migrant protesters demonstrate in Dover against immigration and the journeys made by refugees crossing the Channel to Kent PA UK news in pictures 4 September 2020 Activists take part in a demonstration against the HS2 hi-speed rail line outside the Department of Transport AFP via Getty UK news in pictures 3 September 2020 Peter Baker, who plays Trigger in the musical version of Only Fools and Horses, sweeps the stage of the Theatre Royal Haymarket in London, after observing a 15 minute silence to show solidarity with those in the theatre industry that have lost their jobs due to the coronavirus pandemic PA UK news in pictures 2 September 2020 Kadie Lane, right, 11, and Brooke Howourth, 11, hug on their walk to Marden Bridge Middle School in Whitley Bay, Tyne and Wear, for their first day of term, as schools in England reopen to pupils following the coronavirus lockdown PA UK news in pictures 1 September 2020 Extinction Rebellion protesters sitting outside The Houses of Parliament in Westminster, London PA UK news in pictures 31 August Surfers at Long Sands Beach, Tynemouth PA UK news in pictures 30 August Black Lives Matter protesters march through Notting Hill in London in the first Million People March EPA UK news in pictures 29 August A protester reacts as she demonstrates against the lockdown and use of face masks, amid the coronavirus disease outbreak, outside Downing Street in London Reuters UK news in pictures 28 August Caribbean soca dancers display their costumes as they promote the first ever digital Notting Hill Carnival, following the cancellation of the normal Carnival festivities due to the continued spread of the coronavirus disease, in London Reuters UK news in pictures 27 August Father and son team Chris and Sam Milford from historic building conservation specialists WallWalkers begin restoration work on the spire of Norwich Cathedral, which stands at over 312ft high. The first known spire was completed in 1297 PA UK news in pictures 26 August Giant waves at Seaham in County Durham, as the bad weather continues PA UK news in pictures 25 August An assistant at the Wallace Monument cleans the case which houses the William Wallace sword in the Hall of Arms room at the monument near Stirling as they prepare to re-open PA UK news in pictures 24 August Restored World War Two landing craft LCT 7074 is transported from from the Naval Base in Portsmouth to its final resting place at the D-Day Story at Southsea PA UK news in pictures 23 August Jenny Nguyen and Tony Cao, from Vietnam, pose for wedding photos on Tower Bridge in London, as it remains closed to vehicles after it was stuck open on Saturday due to a "mechanical fault". The landmark's Twitter account confirmed only pedestrians and cyclists could use it on Sunday morning PA UK news in pictures 22 August England's Zak Crawley hit 267, joining the exclusive Double Hundred club, on day two of the Third Test match against Pakistan at the Ageas Bowl, Southampton PA UK news in pictures 21 August Harri Teale gathers lavender during the annual harvest on the Wolds Way Lavender farm near Malton in North Yorkshire PA UK news in pictures 20 August Parents and a student react after checking GCSE results at Ark Academy in London Reuters UK news in pictures 19 August Tate Modern workers hold a strike outside the gallery in London, to protest the institution's announcement that it would cut more than 300 jobs from its commercial arm, Tate Enterprises PA UK news in pictures 18 August Two rescued brown bear cubs, Mish (left) and Lucy, cool off in a pool after arriving at their new home with the wildlife conservation charity Wildwood Trust in Herne Bay, Kent. The orphaned pair, who have been living in a temporary home in Belgium since they were found abandoned and alone in a snowdrift in the Albanian mountains, will be acclimatised to their new life in the country before moving to a permanent home PA UK news in pictures 17 August A level students celebrate outside the Department for Education in London after it was confirmed that candidates in England will be given grades estimated by their teachers, rather than by an algorithm. The government U-turn comes just days after Education Secretary Gavin Williamson vowed there would be "no U-turn, no change. PA UK news in pictures 16 August Wasp players take a knee as Northampton Saints stand prior to kick-off in their Premiership match at Franklin's Gardens PA UK news in pictures 15 August Piper Colour Sergeant Lil Bahadur Gurung attends the VJ Day National Remembrance event, held at the National Memorial Arboretum in Staffordshire, Britain Reuters UK news in pictures 14 August People including students hold placards on Whitehall outside Downing Street as they protest against the downgrading of A-level results. The government faced criticism after education officials downgraded more than a third of pupils' final grades in a system devised after the coronavirus pandemic led to cancelled exams yes AFP via Getty UK news in pictures 13 August Benita Stipp (centre) and Mimi Ferguson (left) react as students at Norwich School receive their A-Level results PA UK news in pictures 12 August 2020 A train derailment near Stonehaven has left three people dead. Driver Brett McCullough, conductor Donald Dinnie, and a passenger were killed when the 6.38am Aberdeen to Glasgow Queen Street service crashed amid heavy rain and flooding BBC UK news in pictures 11 August 2020 A woman hydrates in the sun after open water swimming at the West Reservoir Centre in north London Tolga Akmen/AFP via Getty UK news in pictures 10 August 2020 Prime Minister Boris Johnson takes part in an archery session as he visits Premier Education Summer Camp at Sacred Heart of Mary Girls' in Upminster Reuters UK news in pictures 9 August 2020 People cycle through Cambridge as the heatwave continues in Britain EPA UK news in pictures 8 August 2020 Healthcare workers take part in a protest in London over pay conditions in the NHS Getty UK news in pictures 7 August 2020 Emergency services make their way along the seafront on Bournemouth beach in Dorset on one of the hottest days of the year PA UK news in pictures 6 August 2020 Alison Murphy poses for a picture by husband Peter as she walks through a field of sunflowers in Altrincham, Cheshire PA UK news in pictures 5 August 2020 Pakistan's Abid Ali being bowled by England's Jofra Archer during day one of the First Test match at the Emirates Old Trafford, Manchester PA UK news in pictures 4 August 2020 The 'Timbuktu tumblers' from Kenya perform their balancing act on the Southsea waterfront as Zippos Circus reopens in Portsmouth Rex UK news in pictures 3 August 2020 Pelicans interact with a visitor in St James's Park in London PA UK news in pictures 2 August 2020 Lewis Hamilton drives with a puncture towards the finish line to win the Formula One British Grand Prix at Silverstone POOL/AFP via Getty UK news in pictures 1 August 2020 Arsenal's Pierre-Emerick Aubameyang celebrates with the trophy and teammates after winning the FA Cup, as play resumes behind closed doors following the outbreak of the coronavirus disease Pool via Reuters UK news in pictures 31 July 2020 People enjoy the sunny weather at a Bournemouth Beach Reuters

He was also found guilty of two counts of encouraging terrorism by posting extremist material on Instagram, and two charges of possessing Isis propaganda magazines after jury deliberations lasting for more than four hours.

The teenager was named for the first time following the sentencing hearing on Friday after the judge lifted the automatic anonymity granted to minors in court at the request of journalists.

MI5 and specialist counter-terrorism units in Wales and the West Midlands were involved in the investigation, which culminated in Gunton being detained at his family home near Llantrisant on 30 June.

Detective Superintendent Jim Hall, head of the Wales Extremism and Counter Terrorism Unit (Wectu), said he hoped the sentence would serve as a deterrent to other potential attackers.

“This case has highlighted the ongoing concerns with young people gaining access to extremist material on the internet and how quickly that can lead to radicalisation,” he added.

“Wectu will continue to protect local communities by working with MI5, other partners and the CPS to pursue and prosecute all those who show support for illegal and extremist organisations or who seek to spread hate and terror.”

Thousands of children have been referred to the Government’s counter-extremism programme and the strategy is being reviewed in the wake of revelations that some of the terrorists who committed five attacks in the UK last year were known as potential threats.

A further 10 Islamist and four far-right plots have been foiled in the past year and security services have warned that the terror threat continues to rise.

Authorities are increasing efforts to remove online propaganda of the kind used in the Welsh case, which remains available as Isis continues to use the Telegram messaging app and shifting websites to spread its message.

Ministers have warned that terrorists are using online grooming to inspire potential terrorists, including children and vulnerable people, while the “remote radicalisation” has made plots faster to develop and harder to detect.