Investigators are looking for a motive behind an attack in the German city of Wuerzburg in which a man armed with a knife killed three people and wounded at least five others.
The suspect, a 24-year-old Somali, was shot in the leg by police and arrested after the Friday afternoon attack in the southern city’s central area.
Police said the man’s life is not in danger and he is being questioned in a hospital.
Bavaria’s top security official, Joachim Herrmann, said the suspect had been known to police and had been admitted to a psychiatric unit a few days earlier.
He told the dpa news agency that he could not rule out an Islamic extremist motive, because one witness had reported hearing the suspect shout: “Allahu akbar,” Arabic for: “God is great.”
The man had lived in Wuerzburg since 2015, most recently in a shelter for the homeless. He apparently did not know the victims.
Videos posted on social media showed pedestrians surrounding the attacker and trying to hold him at bay with chairs and sticks.
Michael Dauber, whose shop is near the scene of the attack, said he saw people running away in panic.
“It was unclear for a long time what was happening, then they all started screaming that somebody is stabbing people,” Mr Dauber said. “It was totally crazy.”
Bavarian governor Markus Soeder said: “I was particularly impressed by the dedication of many people who tried to stop the perpetrator and tried to keep him in check.
“That was really impressive dedication, and my thanks for that. Now the circumstances have to be cleared up, the motives.”
Mr Soeder added: “All of Bavaria is in mourning today.” He said he would order flags flown at half-staff in the state.
Wuerzburg police’s use of a shot to the leg to stop the assailant is typical for Germany.
Bavaria’s rules on use of police weapons state that firearms should only be used to make perpetrators unable to attack or flee, and that a shot which is near-certain to kill is only permitted if it is the only way to prevent danger to the life of others.
The rules call for officers to aim at the legs where possible.