BERLIN — A man wielding a large knife fatally stabbed one person and wounded five others on Friday during an attack at a supermarket in Hamburg, Germany, the police said. The assailant was arrested as he tried to flee.

The police said the attacker was a 26-year-old who was born in the United Arab Emirates, but did not release his name. Investigators said they were still trying to determine his citizenship, but Hamburg’s mayor, Olaf Scholz, said it appeared that the attacker was someone who should have been forced to leave Germany. The young man was not deported, Mr. Scholz said, because he did not have the necessary identification and travel documents.

“What makes me angry is that it appears the attacker is someone who sought protection here in Germany and then turned his hate against us,” Mr. Scholz said.

The police declined to offer any information to suggest a motive for the attack, but said they had not ruled out the possibility that it had been an act of terrorism.