Identified as a 26-year-old Palestinian, he arrived in Germany in 2015 from Norway but was due to be deported as his application for asylum was rejected.

Friday’s assault risks reopening a bitter debate over refugees two months before general elections, putting pressure on Chancellor Angela Merkel over her decision to open Germany’s borders in 2015 and let in more than a million asylum seekers.

Merkel expressed her sympathies to victims and their families and vowed that “the violent act must be and will be clarified”.

Investigators were still struggling to determine the exact motive for the assault, which left six people injured.

The suspect “was known as an Islamist but not a jihadist,” said the port city’s interior minister Andy Grote, noting “there are indications of radicalisation”.

But Grote stressed that while there could have been an Islamist motive, the suspect also suffered from “psychological instability”.

“It remains unclear which was the overriding element,” he said.

The Palestinian suspect is being held but has refused to speak about why he staged the attack, Nana Frombach, the spokeswoman for the local prosecutor’s office said.

Germany’s interior minister Thomas de Maiziere also cautioned against jumping to conclusions.

“The jihadist ideology could be used as a justification for action that may actually be motivated by other reasons,” he said, adding that “the real motives could perhaps lie in the personality of the perpetrator.”

The attacker had entered the supermarket and taken a kitchen knife from the shelves.

“He ripped off the packaging and then suddenly brutally attacked a 50-year-old man who later died,” said deputy police chief Kathrin Hennings.

He later wounded two more men in the supermarket before fleeing, hurting four other people along the way, before he was overpowered by courageous passers-by.

The man had brandished the bloodied knife, shouting “Allahu Akbar” (“God is Greatest”) as he fled the scene, but bystanders gave chase and flung chairs to stop him.

– ‘Almost exemplary’ –

If confirmed as an Islamist attack, it would be the first in Germany since Tunisian Anis Amri drove a truck into crowds at a Berlin Christmas market on December 19, killing 12 and injuring 48.

News website Spiegel Online named the supermarket attacker as Ahmad A., while officials said he had not appealed against Germany’s decision to deny him asylum.

In fact, he had helped to obtain documents to facilitate his departure from Germany.

On the day of the attack, he had even gone to the authorities to ask if the papers had arrived. Police chief Ralf Meyer said the suspect was “almost exemplary” in this aspect.

And heavily armed police who searched a Hamburg asylum seekers’ shelter where the man lived failed to find any weapons.

– ‘Started drinking heavily’ –

At the accommodation in a leafy suburb, the suspect’s neighbour, who gave his name only as Mohamed, described him as “very intelligent”.

“He was always helping other asylum seekers with their paperwork,” the 31-year-old Syrian refugee told AFP.

But in recent weeks, he “had a crisis, he bought Islamist clothes and read the Koran very loudly in his room”.

“And three weeks after Ramadan, he had another crisis. He started to drink heavily and smoke joints… he was sad that his mother was ill and that his asylum request was rejected,” recounted Mohamed.

Ahead of elections in September, the latest assault risks rekindling the debate over the record refugee influx.

“It makes me especially angry that the perpetrator appears to be a person who claimed protection in Germany and then turned his hate against us,” said Hamburg mayor Olaf Scholz.

“What was this man doing in Germany?” the mass-circulation Bild newspaper asked.