Federal prosecutors, who handle terrorist attacks, have not yet taken over the case, he said.
But Fridayâs attack is sure to draw parallels to the Dec. 19 truck attack on a Berlin Christmas market carried out by Anis Amri that killed 12 and wounded dozens. Like the Hamburg attacker, Mr. Amri was known to the police and was facing deportation, but still managed to slip through cracks.
Unlike Mr. Amri, who pledged loyalty to the Islamic State group, the Hamburg attacker has been cooperating with the authorities, who were trying to acquire identification papers for him from the Palestinian Authority, which are required for his deportation.
The authorities were alerted to the possible radicalization of the man after one of his friends contacted security officials, said Torsten Voss, director of Hamburgâs state intelligence agency.
âA friend of his told us that this guy used to frequently drink alcohol, but recently he had noticed a change,â Mr. Voss said, describing the friendâs conversation with officials in August 2016. âThey said he started talking a lot about the Quran, stopped drinking alcohol and questioning many things.â
But last year an evaluator who interviewed the Palestinian â who spoke fluent English, Swedish and Norwegian â said that while he had mental health problems, he did not pose an imminent danger, Mr. Voss said.
The police have opened an investigation to piece together a motive for the assault, and they are looking through his cellphone and other items found in his home, said Kathrin Hennings, a spokeswoman for Hamburg police.
Germanyâs interior minister, Thomas de MaiziÃ¨re, expressed horror at the latest attack, but he cautioned against jumping to conclusions before the police finished their investigation.
âPainful experience also teaches us that we must expect that jihadist ideology will be used as the reason or justification for acts that are perhaps carried out for very different reasons,â Mr. de MaiziÃ¨re said. âThe true motive can also lie in the perpetratorâs personality. This is being investigated in Hamburg.â
Flowers and candles arranged in the shape of a peace symbol were laid out on the sidewalk in front of the supermarket in the northern district of Barmbek, where the attack took place on Friday.
Before the attack, the man had entered and then left the store, Ms. Hennings said. When he returned, he approached a man selling kitchen knives, grabbed one and fatally stabbed him, she said.
âHe ripped off the packaging and then suddenly, brutally attacked the 50-year-old man, who later died,â Ms. Hennings said.
The attacker then stabbed other people, wounding a woman and four men as he left the store. Outside the store, passers-by tried to disarm him, she said.
Amateur video footage showed a group of men throwing chairs and other objects at the attacker in an attempt to stop him before the police arrived and detained him. One of the men was injured during the encounter, they said.