A schizophrenic man repeatedly stabbed a train passenger in an unprovoked attack after yelling "I want to kill all the Muslims", a court has heard.
Adrian Brown, 38, was said to have been experiencing a "severe psychotic episode" when he stabbed Muhammed Ali on a London Overground train last year.
Southwark Crown Court heard other passengers saved Mr Ali's life.
Mr Brown agrees he carried out the attack, but denies attempted murder on the grounds of insanity.
Prosecutor Alan Kent QC said Brown, of Brockley Rise in south-east London, left the hostel he was staying in on 12 December armed with a knife and headed to Honor Oak Park.
He added Brown was determined to find and kill Muslim men.
"He walked up and down the train threatening passengers, threatening death to Muslims while looking for any Muslim men to stab and kill.
"He saw the victim, Mr Muhammed Ali, who was sitting on the train with his wife. The defendant approached Mr Ali, who was sitting down, and repeatedly stabbed him to his head and his body."
Mr Ali suffered injuries to his head and torso as well as a punctured lung.
Mr Brown is also accused of carrying a knife and assaulting Filipe Dias, who worked at the hostel, during an earlier incident, both of which are denied on the grounds of insanity.
The court heard Mr Brown had become agitated over a lack of hot water and set upon Ms Dias, who had previously confiscated knives from him.
Mr Kent told jurors that after attacking Ms Dias, he left saying "I'm going to kill some Muslims".
Jurors at the trial of issue must decide if Brown was insane at the time of the attack.
The court has heard that two psychiatrists have determined he was.
The trial continues.