HAMBURG (Reuters) - A 26-year-old migrant to Germany who was supposed to leave the country went on a stabbing spree with a kitchen knife in a Hamburg supermarket on Friday, killing a 50-year-old man and leaving six others injured, police and city officials said.

Slideshow ( 18 images )

Germany is less than two months away from parliamentary elections on Sept. 24 in which Chancellor Angela Merkel is likely to win a fourth term despite tensions about her decision in August 2015 to open the door to over one million migrants. Security has been a big issue in the campaign.

Passersby threw chairs and other objects at the attacker as he fled the scene, enabling plain clothes police officers to take him into custody near the store, according to police and videos posted on Twitter.

Police said the man, who was born in the United Arab Emirates, suddenly began attacking customers in a supermarket in the northern city on Friday afternoon.

Hamburg Mayor Olaf Scholz said in a statement that the assailant was “apparently a foreigner who was supposed to leave the country,” but could not be deported because he did not have the necessary identification papers. Police said they were still trying to determine his citizenship.

“It’s also infuriating that this perpetrator is someone who asked for protection in Germany and then turned his hate against us,” Scholz said.

A police spokeswoman said she could not confirm that the attacker shouted “Allahu Akbar”, Arabic for “God is Greatest”, as he ran out of the supermarket, as one witness told German broadcaster n-tv.

Bild newspaper reported late on Friday that armed police forces had searched the migrant housing center where the attacker had lived.

The police spokeswoman said the motive for the attack was still under investigation. She said she had no information that the attacker was known to authorities as an Islamist, as reported by the newspaper Tagesspiegel.

Police said a 50-year-old woman and four men aged between 19 and 64 were injured in the attack, all of whom were German. A 35-year-old Turkish man was also injured while trying to stop the attacker, they said. Media reports said he injured his shoulder while throwing a metal rod at the attacker.

Police have been on high alert in Germany since a spate of attacks on civilians last year including a December attack on a Berlin Christmas market, when a hijacked truck plowed into the crowds, killing 12 and injuring many more.

The man responsible for that attack was also denied asylum, but had not been deported because authorities were waiting for his home country of Tunisia to issue identification papers.

Bild showed a picture of a man said to be the Hamburg attacker sitting in the back of a police car, his face concealed with a bloodied shroud.

A video on Bild’s website showed a helicopter landed outside the supermarket with armed police in body armor patrolling the neighborhood.