The 26-year-old man grabbed a long kitchen knife at a supermarket Friday afternoon and stabbed three shoppers, killing one, before attacking four others on the street.
Eyewitnesses said he shouted, ''Allahu akbar,'' or God is greatest. Amateur video showed young men throwing chairs at the suspect to subdue him.
One of the injured was a Turkish man who helped others overpower the attacker, authorities said. Some of the injured were hurt seriously.
''We are shaken, horrified,'' Hamburg Interior Minister Andy Grote said at a Saturday news conference. He called it a ''barbaric'' attack and praised the citizens who overpowered the man as ''very courageous.''
The attack was the latest in a series linked to Islamists in Germany, including a December truck attack on a Christmas market in Berlin that killed 12 people.
Grote said the attacker appeared to have Islamist motives but was also ''psychologically unstable.'' He was known to be undergoing radicalization, and authorities were monitoring him but didn't consider him to be an Islamist militant. Authorities searched his living quarters at an asylum shelter in Hamburg overnight.
Torsten Voss, Hamburg state's chief of the Constitutional Protection Office, said the suspect was one of 800 registered Islamists under observation in Hamburg, but that he was so far not linked to any extremist network.
Voss said the attacker, according to an informant, was known in the past to enjoy drinking and partying, but had changed recently and increasingly spoke about the Koran. The suspect speaks Norwegian, Swedish and English, he said.
Two German security officials said the suspect in the Hamburg knife attack was on the radar screen for expressing pro-jihadi views.
The state domestic intelligence service in Hamburg had flagged him, the officials told CNN, but the suspect was not considered a priority cause for concern because the depth of his radicalization was not clear.
One official said the attack appears to be the latest in a series of "borderline cases" in Europe and the United States where it is difficult to untangle mental health problems from terrorist motivation.
Nationality is unclear
Hamburg's mayor was to lay flowers at the site of the attack in the city's Barmbek area, Grote said.
The suspect was to appear in court Saturday on one count of murder and five counts of attempted murder, said Joerg Froehlich, Hamburg chief prosecutor.
He won't talk because of a head injury sustained during the attack, Froehlich said, adding that the case will go to the federal prosecutor. The suspect, whom the authorities did not identify by name, had previously been arrested for shoplifting.
Authorities are trying to determine the man's nationality but said he had a birth certificate from the United Arab Emirates and was seeking papers from the Palestinian Authority mission in Berlin.
Grote said the man intended to leave Germany and had been at a government registration office for foreigners earlier Friday to see if his papers had arrived.