WUERZBURG, Germany (AP) — The suspect in a knife attack in southern Germany that left three women dead was ordered kept in custody Saturday on suspicion of murder, while authorities puzzled over a possible motive, examining his mental health and seeking to determine whether he was radicalized.

The attack started late Friday afternoon when the suspect walked into a store in Wuerzburg, went to the household goods department and asked a saleswoman where the knives were, regional police chief Gerhard Kallert said. He then grabbed a knife and fatally stabbed three women in the store, before continuing to attack people outside. Six people, most of them women, were seriously injured, and one of them remained in a life-threatening condition on Saturday.

Videos posted on social media showed people surrounding the attacker and trying to hold him at bay with chairs and sticks. The 24-year-old Somali was then stopped with a shot to the leg by police and arrested.

On Saturday, he was brought before a judge, who ordered him held in jail pending a possible indictment on suspicion of three counts of murder, six of attempted murder and dangerous bodily harm; and another of bodily harm.

The man arrived in Germany in May 2015 and was granted “subsidiary protection,” a status that falls short of full asylum. He had been in Wuerzburg since 2019, and was living in a homeless shelter.

Officials said he didn't have a criminal record, but there were two incidents earlier this year that resulted in him being sent briefly to a psychiatric hospital. In January, he got into an argument with residents and staff at the shelter and brandished a kitchen knife, prosecutor Wolfgang Gruendler said.

He didn't attack or hurt anyone, but an investigation was opened and he was temporarily admitted to a psychiatric hospital. That investigation is still ongoing and a psychiatric evaluation is still outstanding.

Earlier this month, there was an incident in which someone gave him a lift and he didn't get out of the car. That again resulted in his admission to a psychiatric unit, but he was released after a day, prosecutors said. They said there had been no pattern of increasing problems.

Authorities also were looking at the possibility of the man having been radicalized as an Islamic extremist. Kallert said a store detective and police officers reported hearing the suspect say “Allahu akbar,” Arabic for “God is great." Bavaria's top security official, Joachim Herrmann, said that “further cautious indications” in that direction emerged from his questioning, without elaborating. Material with “hate messages” also was found but has yet to be evaluated, police said.

As to whether the man was mentally ill or radicalized, “we don't know either one thing or the other for sure at the moment, but I just want to note that they don't rule each other out,” Herrmann said. Authorities were examining a mobile phone and other evidence.

The case was handed over to prosecutors in Munich, the state capital, but not to federal prosecutors, who in Germany deal with terror cases.

A fellow resident of the shelter who said he was among 10-12 people who tried to stop the suspect stabbing anyone else until police arrived on Friday described the man as being “always alone, not talking to the other people.” He added that "he was strange all the time.”

“Thank God we people managed to scare him a little bit, distract him, he got tired, and thank God it didn’t turn out even worse,” the man, whose name was given only as Kadir A., told RTL television.

Herrmann described using a shot to the leg to stop an assailant as a “textbook" move. Bavaria’s rules on use of police weapons state that firearms should only be used to make perpetrators unable to attack or flee, and that a shot which is near-certain to kill is only permitted if it's the only way to prevent danger to the life of others.

The rules call for officers to aim at the legs where possible.

——

Geir Moulson reported from Berlin.

Copyright 2021 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed without permission.