The man was arrested after the attack on Wednesday afternoon in the quiet town of Vetlanda in the south of Sweden, home to some 13,000 people.
“He was remanded in custody, suspected of seven counts of attempted murder on March 3rd in Vetlanda,” judge Anna Sjöman told AFP.
She said the court determined he was at risk of fleeing, which could inhibit the investigation or increase the risk of further crimes.
The suspect was treated in hospital after being shot in the leg by police during the initial arrest, but appeared in court for the hearing on Friday.
According to several media reports, the man, who denied the crime through his lawyer, was agitated during the hearing and shouted that he “hadn’t done anything”.
Prosecutors will need to decide on whether to press charges against the man by March 19th.
Police have said the suspect has an Afghan citizenship and that the case is being investigated as attempted murder, but they are also looking into whether he had a “potential terror motive”.
Swedish media outlets also reported that the man had arrived in Sweden in 2016 and was awaiting a decision on an extension to his residence permit.
Details of the man’s struggles with mental health have also emerged. Aftonbladet reported that the suspect had spoken about having psychiatric problems himself in an interview with police when he was suspected of a minor narcotics offence a few years earlier.
All the victims were men, with three of them receiving life-threatening injuries, according to health authorities, but on Thursday they were all reported to be in stable condition.