The 24-year-old suspect staged the attack in the city centre at around 5 pm (1500 GMT), striking at a household goods store, before hitting a bank.
The man, who has lived in Wuerzburg since 2015, was overpowered after police shot him in the thigh, said Bavaria’s interior minister Joachim Herrmann.
The rampage left “three dead, five seriously injured and others injured,” said Herrmann, adding, “it is not certain if the most seriously injured will survive”.
Investigators have found documentation showing the man “was treated in a psychiatric institution”, said Herrmann, but added that he could not detail the length of the stay.
“The police investigation will determine if this was an Islamist act or if it was due to the psychiatric state” of the man, he said.
A witness had reportedly said the suspect “shouted Allah Akbar” (God is greatest) during what rescuers described as a “really incredibly brutal” attack, said Herrmann.
“That must all be clarified in further interrogations but we have no further indications on the motivations,” he added.
Police said however that the suspect was not a known terrorist.
The mass-circulation daily Bild published a photo of the suspect, showing a man wearing a beige, long-sleeved t-shirt with grey trousers and holding a long knife.
Video footage circulating online also showed passers-by trying to stop the suspect using folded chairs.
A crowd of people gave chase before a police car arrived on the scene, one video showed.
Another photo published by Bild showed a police officer handcuffing the suspect.
A huge police deployment was underway in the city of around 130,000 inhabitants located about 120 kilometres (75 miles) west of Frankfurt.
While the perpetrator’s motive has not yet been established, Germany has been on high alert after several deadly extremist attacks.
– Dangerous suspects –
Wuerzburg was itself hit five years ago by an axe-wielding man who seriously wounded four people o a train.
The suspect, an Afghan, sought to attack a passerby as he fled before being shot dead by police.
The attack was claimed by the Islamic State (IS) terrorist group.
The deadliest terrorist attack in Germany happened in December 2016 when a Tunisian IS supporter rammed a truck into a Berlin Christmas market killing 12 people.
More recently, one man was killed and another seriously injured in a knife attack in the city of Dresden in October.
A 20-year-old Syrian terrorist in May received a life sentence for the homophobic attack.
Last August, six people were injured in a series of motorway accidents in Berlin in what prosecutors described as a suspected terror attack.
Since 2009, German authorities have foiled 17 suspected terror attacks motivated by IS — the majority in 2016, according to the interior ministry.
The number of terrorists considered dangerous in Germany rose sharply between 2015 and 2018, according to security services.
But the numbers have declined since then, with 615 considered dangerous by the latest count compared with 730 in January 2018.
There are also 521 people “who have attracted the attention of the security services but have not yet reached the stage of being considered dangerous”.