A Somali man killed three people and left five others seriously injured in an "incredibly brutal" knife rampage in the southern German city of Wuerzburg.

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 Islamist.

The mass-circulation daily Bild published a photo of the suspect, showing a dark-skinned 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 Islamist extremist attacks.

The suspect had been treated in a pyschiatric institution recently, Bavaria's interior minister said
The suspect had been treated in a pyschiatric institution recently, Bavaria's interior minister said dpa / Karl-Josef Hildenbrand

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) jihadist group.

The deadliest Islamist attack in Germany happened in December 2016 when a jihadist rammed a truck into a Berlin Christmas market killing 12 people.

The Tunisian attacker, a failed asylum-seeker, was an IS supporter.

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 jihadist 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 Islamist attack.

Since 2009, German authorities have foiled 17 suspected jihadist attacks -- the majority in 2016, according to the interior ministry.

The number of Islamists 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".

In 2020, 320 new investigations with a link to the Islamist threat were launched in Germany.

Germany remains a target for jihadist groups, in particular because of its involvement in the coalition fighting IS in Iraq and Syria, and its deployment in Afghanistan since 2001.

The far-right Alternative for Germany (AfD) party has meanwhile charged that Chancellor Angela Merkel's decision to allow in more than one million asylum-seekers -- many fleeing Iraq and Syria -- since 2015 has contributed to the heightened security risk.

But beyond Islamist attacks, there have been other knife assaults.

In October 2017, a man randomly attacked passers-by with a knife in central Munich, lightly injuring eight people. Police excluded terrorism as a motive after detaining a suspect.