As a knife-wielding man sought to flee after killing one and injuring several at a Hamburg supermarket, several passers-by gave chase and tackled him to the ground, said witnesses.
"People ran after the attacker and threw chairs at him," 18-year-old Shaylin Roettmer told the national news agency DPA.
Police also confirmed that they were alerted to the attack by witnesses, who had given chase and overpowered the suspect.
Plainclothes officers captured the man, who was slightly injured.
Police identified the attacker as a 26-year-old man, born in the United Arab Emirates.
The man had struck this afternoon at a popular supermarket on a busy high street in the northeast of Hamburg, Germany's second city and host of early July's G20 summit of world leaders.
He stormed into the supermarket with a "huge knife," an unnamed woman told news channel NTV.
"I thought I was in a horror movie, I thought he would kill me," she said.
She said she feared she would die, as she was "queueing for the till and couldn't get away".
"As he was running out... he held up his arms and shouted 'Allahu Akbar'," she added.
On the run, the suspect struck a young girl on the street, another witness told NTV.
Hamburg resident Remo Pollio told DPA that as the man was running away, "he held up the knife and shouted 'Allahu Akbar', he did that twice."
A police spokeswoman said she was unable to confirm the "Allahu Akbar" ('God is greatest' in Arabic) accounts.