Lawyers representing Muhiddin Mire told the Old Bailey his delusions included the belief that Tony Blair was his “guardian angel”, as part of paranoid schizophrenia dating back several years.
The 30-year-old attempted to behead a passer-by in December with a rusty blade in Leytonstone and slashed another man in the neck while shouting about the Syrian war.
He was found guilty of attempted murder last month but on Wednesday the court heard he needed ongoing psychiatric treatment during the first day of a sentencing hearing.
Mire, a Muslim born in Somalia, has a history of mental illness and psychosis, including the belief that he was being persecuted for his religion and stalked by MI5 and MI6.
The court heard the taxi driver has been diagnosed with paranoid schizophrenia and suffered his first episode of psychosis in 2006.
Mire appeared in the dock for the hearing wearing a blue tracksuit and flanked by several dock officers.
Dr Shaun Bhattacherjee, a consultant psychiatrist treating Mire at Broadmoor Hospital, said he was “clearly mentally ill”.
"It is clear at the time of the offence he was very psychotic and manifested a significant number of psychotic symptoms," he told the court. Mr Bhattacherjee said that Mire posed a "very severe" risk to the public and needs ongoing psychiatric treatment.
"Because of the significant risk to the safety of others,” he added. “It's necessary that that treatment is continued in conditions of high security."
Alphege Bell, a lawyer for the defence, said Mire suffered from a number of unfounded beliefs, including that the former prime minister "Tony Blair was his guardian angel". He also thought he was possessed by evil spirits and underwent a number of "exorcisms" by imams, the court was told.
Mire had been referred to mental health services by his GP a month before the attack but was not taking medication, and had recently started to wear traditional clothes rather than his usual jeans and T-shirt. The defendant’s family were also concerned about his mental state and had contacted police, as well as unsuccessfully trying to persuade him to travel back to his native Somalia.
Defence witness Dr Nigel Blackwood, a senior lecturer at King’s College and consultant psychiatrist at HMP Wandsworth, said Mire’s extremism was “intimately associated” with mental illness.
Cannabis use made a "significant" contribution to what was "probably" a case of paranoid schizophrenia, according to consultant forensic psychiatrist Dr Philip Joseph.
But prosecutors argued Mire had watched Islamist videos for several years and was deliberately trying to recreate an Isis beheading with his attack. Mire had images of Fusilier Lee Rigby, who was murdered by extremists in 2013, on his phone as well as pictures of Mohammed Emwazi, the British Isis terrorist known as Jihadi John, and material linked to the terrorist group.
Mire had travelled on the same Central Line train from Stratford as his victim, Lyle Zimmerman, on 5 December.
He followed him out of the carriage and produced from his pocket a black-handled knife with a serrated edge, pushing the musician to the floor as he approached the barriers.
Mire kicked him repeatedly in the head and body as a woman called out for him to stop, then crouched down and began to “saw” at his neck with the serrated blade in front of shocked passengers.
A junior doctor on his way home rushed in to help stem the blood flowing from Mr Zimmerman's neck as Mire went up to street level.
In a statement read during Mire's sentencing hearing, he said he was lucky to have survived. "I have been left with a scar on my neck which I am aware of only because it pulls when I use my voice but is otherwise superficial and healing well," he said.
"I am somewhat more cautious about interacting with strangers since the attack. Overall I have not been significantly traumatised by the attack psychologically.”
Prosecutor Jonathan Rees QC praised him for his “philosophical view” of his injuries and commended the bravery of passers-by who intervened in the attack.
Mire lashed out at Serena Valori before coming face to face with Russian security guard Andrius Sabaliauskas, who tried to talk to him. But despite the efforts to calm him down, Mire tried to slash lift engineer David Pethers before police arrived with tasers.
Mire ran at an officer and the security guard, shouting: “This is for my Syrian brothers. I'm going to spill your blood,” before he was finally subdued.
An onlooker was heard shouting, “You ain't no Muslim, bruv”, after Mire claimed he was carrying out the attack for “my Syrian brothers” and shouted “Allahu Akbar” as police took him down with Tasers.
No formal link to Isis was uncovered but terrorism specialists at Scotland Yard are warning that the group is deliberately targeting mentally ill people with propaganda.
After last month’s guilty verdict Commander Dean Haydon, head of the Metropolitan Police Service Counter Terrorism Command, said Mire was “inspired by Isis” to carry out the unprovoked attack. “This was a random attack, completely unprovoked,” he added. “He wasn't a member of Isis [but] he was inspired by Isis.”
Judge Nicholas Hilliard QC, Recorder of London, said he could not pass sentence on Wednesday because of the need to consider Mire's mental health problems. “There are obviously a whole range of options as far as the offence of attempted murder is concerned,” he added. “That includes the possibility of an indeterminate custodial sentence at one end and the possibility of a hospital order at the other.”
His sentencing remarks will be video-recorded as a pilot case exploring the potential for public broadcasting of court hearings.
Additional reporting by PA