A teenage Islamic State fanatic has been jailed for life for plotting a terror attack on British police officers or soldiers after being radicalised online in the pandemic.

Muslim convert Matthew King, 19, expressed a desire to kill military personnel as he prepared to stake out a British Army barracks in Stratford, east London.

He discussed his plans and shared a “gory fantasy” with an online girlfriend with whom he struck up an adolescent flirtation, the Old Bailey heard.

His desires to launch an attack in Britain or travel to Syria to join so-called Islamic State were thwarted when his mother reported him to the Prevent counter-terrorism programme.

Authorities were also tipped off through an anti-terrorist hotline after he posted a video on a WhatsApp group on April 13 last year.

While in custody, King had made a violent threats to “behead an imam” and “kill and chop up staff”, the Old Bailey was told.

In January, King, from Wickford, pleaded guilty to preparation of terrorist acts between December 22 2021 and May 17 2022.

On Friday, he was handed a discretionary life sentence with a minimum term of six years in the first terrorism sentencing in England and Wales to be televised.

Judge Mark Lucraft KC praised King’s mother, saying: “She took the very bold step of alerting Prevent when she had concerns for her son. That cannot have been an easy thing to do in the first place and in my view she absolutely the right thing.”

Judge Lucraft found King was a dangerous offender and carried a risk of future harm to the public, despite claims by his barrister the defendant was on the path to deradicalisation.

In mitigation, Hossein Zahir KC said King was “immature” and the prospect he would carrying out either of his terrorist plans were “remote”.

The defence barrister argued that despite incidents of “offensive and abusive” behaviour in custody, King was “slowly and steadily” disengaging from the excesses of extremism.

After the sentencing, Scotland Yard described King as a “committed, self-initiated terrorist” who was “self-radicalised” online during the Covid-19 pandemic.

Commander Dominic Murphy, who leads the Met’s counter terrorism command, said: “We had seen an escalation in Matthew King’s behaviour, in his reconnaissance, in his online activity.

“I genuinely believe this was an imminent terrorist attack. Without the public’s help and without the efficient investigation of my officers, officers from the eastern region and members of the intelligence community, we wouldn’t have been able to disrupt what, for me, was an imminent attack.”