The judge said that claim was “in substantial conflict” with the prosecution case and would be addressed alongside other contested facts at a Newton hearing, which is expected to last for a week.

Prosecutor Alison Morgan QC said the prosecution maintained that there was a “substantial degree of premeditation” by Saadallah.

She said the murders were committed “for the purposes of advancing a political, religious or ideological cause”, which is the definition of terrorism in UK law.

Ms Morgan said the prosecution would be arguing for a rare whole life order, meaning that Saadallah would never be freed from prison.

“It is not accepted by the prosecution that the defendant’s mental health issues diminish the culpability,” she added.

Saadallah was known to British security services and had been flagged to the government’s Prevent counter-extremism scheme before the attack.

He was not found to have a fixed ideology and was offered other forms of support, The Independent understands.

The Libyan asylum seeker had come on to MI5’s radar in 2019 over intelligence that he may have wanted to travel out of the UK to wage jihad abroad, but a full investigation was not deemed necessary and no journey took place.

Saadallah, who moved to Britain in 2012, was receiving support for mental health issues.

He had six previous convictions for 11 crimes between June 2015 and January last year, according to a 2019 Court of Appeal judgment.

Saadallah’s offences included racially aggravated assault, knife offences and criminal damage.

He was originally jailed for 25 months and 20 days in October 2019 for a string of crimes but the sentence was later reduced.

Saadallah, who lived in Basingstoke Road in Reading, had his overall term cut to 17 months and 20 days behind bars at the Court of Appeal in March this year.

His mental health problems were noted by Mr Justice Goss, one of the appeal judges who handed down the judgment.

According to the court papers, he had a history of debt and homelessness, alcohol and substance misuse, and “suffered from the effects” of post-traumatic stress disorder, depression and a personality disorder.

In the document he was also described as being “aggressive and unpredictable”.

In the judgment Mr Justice Goss said the sentencing judge had “observed that numerous outside agencies had attempted to help him, but he kept on committing deeply unpleasant violent offences”.

In November 2018 he called a police officer a “slave” and spat in her face while being detained under the Mental Health Act in response to reports he was attempting suicide.

Saadallah admitted possessing a bladed article and criminal damage after being found “apparently very drunk” by police officers the following month, with a butter knife in his waistband, claiming he was “out for revenge” after being attacked.

While in custody he defaced a copy of the police code of practice “with his own excrement”.

In January 2019, he hit a security guard in the face with his belt after being challenged for shoplifting.

In September 2019, Saadallah was jailed for 10 weeks after admitting spitting at a judge who was sentencing him for two convictions at Reading Magistrates' Court.

Saadallah had also breached an earlier suspended sentence for carrying a knife in a plastic bag at a supermarket, according to the court papers.

The judge adjourned sentencing until the week of 7 December.

Reference: Independent: Lizzie Dearden: