A man who stabbed three people to death in a Reading park believed he was carrying out "an act of religious jihad", a court has heard.
Khairi Saadallah, 26, stabbed to death James Furlong, 36, David Wails, 49, and Joseph Ritchie-Bennett, 39, during the attack in Forbury Gardens in June.
As part of his sentencing, a hearing will decide if he was motivated by a religious or ideological cause.
The prosecution claim the stabbing spree was a terror attack.
Saadallah has admitted three counts of murder and attempted murder, but denies he was motivated by an ideology.
Prosecutor Alison Morgan QC told the court he "executed" his victims and intended to "kill as many people as he could" in the name of violent jihad.
She said: "In less than a minute, shouting Allahu Akhbar the defendant carried out a lethal attack with a knife, killing all three men before they had a chance to respond and try to defend themselves.
"Within the same minute, the defendant went on to attack others nearby, stabbing three more people, Stephen Young, Patrick Edwards and Nishit Nisudan, causing them significant injuries."
Stating the prosecution's case she said the attack was "carefully planned and executed" by the defendant with "determination and precision".
She added: "The defendant believed that in carrying out this attack he was acting in pursuit of his extreme ideology, an ideology he appears to have held for some time.
"He believed that in killing as many people as possible that day he was performing an act of religious jihad."
After the attack Sadallah fled but was chased down by police, and later admitted the attacks in his cell, the court heard.
In interviews with police he "howled like a dog" and claimed to have magic powers, which the prosecution said was a "disingenuous" attempt to suggest he had a mental disorder.
"After a careful period of assessment and treatment at Belmarsh prison, it is clear that he does not have a major mental illness", a report by a psychiatrist read out in court said.
Saadallah arrived in the UK as an asylum seeker in 2012, having fled the civil war in his home country of Libya in North Africa.
The court heard the defendant, who had been refused asylum, had been involved with militias as part of the uprising against Muammar Gaddafi.
Between 2013 and 2020 he was repeatedly arrested and convicted of various offences in the UK.
While in HMP Bullingdon, Saadallah was observed to be keen to interact with radical preacher Omar Brooks - associated with banned terror group Al-Muhajiroun - who was also at the jail at the time, the court heard. He was released from the prison in June, days before the attack.
Saadallah had been due to be deported, but was told by the government circumstances in Libya at the time were a "legal barrier".
The court was told he had also searched on the internet "how to disappear with magic" and accessed a website with the flag associated with Islamic State.
A probation officer who had contact with Saadallah flagged his concerns about his mental health, but a psychiatrist has since concluded the attack on June 20 was "unrelated to the effects of either mental disorder or substance misuse".
Saadallah, of Basingstoke Road in Reading, launched his attack as people enjoyed a summer Saturday evening in Forbury Gardens on 20 June.
Eyewitnesses said he walked along a footpath when he suddenly ran towards a group of men sitting on the grass.
History teacher Mr Furlong and Mr Ritchie-Bennett, a US citizen, were both stabbed once in the neck, while scientist Mr Wails was stabbed in the back.
All three were pronounced dead at the scene.
Three others - their friend Stephen Young, as well as Patrick Edwards and Nishit Nisudan, who were sitting in a nearby group - were also injured by Saadallah.
The sentencing before Mr Justice Sweeney is expected to conclude on January 11.