Investigators said Saturday they were examining if radicalisation or psychiatric problems drove a 24-year-old man to go on a knife rampage in the German city of Wuerzburg, stabbing three women to death and leaving six other people seriously injured.
The suspect, a Somali who arrived in Germany in 2015, struck in the city centre on Friday evening, first at a household goods store before moving on to a bank.
He was then overpowered by police after they shot him in the thigh.
Investigators found records showing that the man had been treated at a psychiatric institution, and police said he was previously not a known Islamist.
But a witness account of the suspect crying 'Allah Akbar' (God is greatest) during his killing spree fuelled questions over his motive.
Bavaria interior minister Joachim Herrmann said police were still combing through the evidence including two mobile phones.
But he stressed that 'the indications of a possible radical Islamist mindset and the indications of a possible psychiatric issue of the perpetrator do not exclude each other'.
Chancellor Angela Merkel said 'what is certain is that the horrific act is directed at all humanity and every religion', her spokesman Steffen Seibert tweeted.
But the far-right AfD party immediately seized on the violence that has erupted just three months before general elections.
The anti-immigration party's co-leader Joerg Meuthen lamented the latest 'Islamist knife murders in the middle of Germany,' adding that it was a 'tragedy for the victims, who have my sympathy and another manifestation of Merkel's failed migration policy'.
The AfD has railed that Merkel's decision to allow in more than one million asylum-seekers many fleeing Iraq and Syria since 2015 has contributed to a heightened security risk.
Spiegel Online reported the suspect had said in an interrogation that the act was his 'jihad'.
Bild daily said police found propaganda material from the Islamic State jihadist group in the rubbish bin of the homeless shelter where the suspect had been living.
Police said they could not confirm the reports.
If confirmed as an Islamist act, the case risks reopening a bitter debate in Germany over immigration a topic that has taken a backseat so far in this year's election campaign, compared to the last polls in 2017 when the AfD won seats in parliament for the first time.
'Sad and shocked'
In the Bavarian city, residents placed flowers and candles at the scene.
'I'm extremely sad and shocked and that's why I'm here. I find that's the least one can do show sympathy,' said Wuerzburg resident Franziska, who brought candles with a friend.
President Frank-Walter Steinmeier voiced shock at the 'extreme brutality' of the crime, saying that the country was in mourning with the relatives of the victims.
One of the six seriously hurt was still in a critical condition, police said.
Investigators piecing together the attack said the suspect had gone into the household goods store where he approached a saleswoman to ask where he could find knives.
After he took hold of a knife, he turned back to the saleswoman and stabbed her "many times", killing her, said police chief for the Unterfranken region Gerhard Kallert.
He then fatally stabbed two other women before leaving the store.
Video footage circulating online showed passers-by, some armed with folded chairs, trying to stop the suspect.
A crowd of people gave chase before a police car arrived on the scene, one video showed.
While the perpetrator's motive remains unclear, Germany has been on high alert after several Islamist attacks.
Wuerzburg was itself hit five years ago by an axe-wielding man who seriously wounded four people on a train.
The suspect, an Afghan, sought to attack a passer-by before being shot dead by police.
The attack was claimed by the IS group.
In Germany's deadliest Islamist attack, a Tunisian jihadist rammed a truck into a Berlin Christmas market in December 2016, killing 12 people.
The number of Islamists considered dangerous in Germany stands at 615 at the last count, compared with 730 in January 2018.