At least three people are said to have been killed and five wounded in Würzburg knife attack according to local authorities.
A viral video on social media showed a man armed with a large knife being confronted and subdued by passers-by.
The suspect, a Somali man, aged 24, was shot in the thigh before being arrested.
Police said he had been violent and mentally unstable and had recently received psychiatric treatment.
Police were alerted to the Würzburg knife attack at around 17:00 local time (15:00 GMT), in the city centre’s Barbarossa Square.
Bavarian Interior Minister Joachim Herrmann speaking on the Würzburg knife attack, told reporters that, of those who were injured, five were in serious condition and it was “not certain” if they would survive.
The suspect is being questioned at a local hospital.
Officers are also searching his home and investigating his contacts for further evidence.
A witness reported that the suspect shouted “Allah Akbar” during the attack, said Mr Herrmann.
But a police spokesman said that, while the attacker had a criminal record, none of his previous offences were related to terrorism.

