On Friday, Police Chief Niclas Hallgren told Swedish public service radio said that the man who killed two people at a school in Trollhättan “was driven by racist motives.”

"We are convinced that the assailant was driven by racist motives when he carried out the act," he said. "We have reached this conclusion based on what we found when we searched his apartment and his behavior during the act, and also on the basis of how he selected his victims."

An adult male teacher died at the scene. The second person died while undergoing surgery at 2:30 p.m. local time, DN newspaper cited police as saying.

“A single man went into the school building...and he injured four persons – two male adults and two boys," police media officer Stefan Gustafsson told RT.

The press secretary of NAL hospital, Niklas Claesson, told RT by phone that “two kids (11 and 16 years of age), one teacher and the suspect" were brought in for medical help.

The attacker was shot and injured by police and later succumbed to his wounds at the hospital, Aftonbladet newspaper reported.

”A terrible tragedy”, will take time to investigate, police say. Killed teacher adult man, injured youths are male, no more details. — Carl Fridh Kleberg (@FridhKleberg) October 22, 2015

Gustafsson said a suspect armed with a "sword of some kind or a large knife” entered the Kronan School at about 10:10 a.m., and that police drew their weapons at the scene.

Enligt media sägs skolan i #Trollhättan vara en grundskola 1-9. Bilderna visar enbart vuxna. pic.twitter.com/Vh0rDR6pgA — Mogmanski (@mogmanski) October 22, 2015

“We know nothing at all [about the attacker],” he said, adding that the suspect was taken to hospital after being shot by police.

A student at the school told The Local: “I was in a classroom with my class when one of my classmates’ sisters called her to warn her that there was a murderer at the school. So we locked the door to the classroom, but our teacher was still outside in the corridor.

We wanted to warn him, so a few of us went outside and then I saw the murderer, he was wearing a mask and had a sword. Our teacher got stabbed. The murderer started chasing me. I ran into another classroom. If I had not run, I would have been murdered.”

Some reports say the attacker was wearing a Star Wars mask.

The attack occurred in the school cafeteria, prompting Trollhättan Municipality to deploy its crisis team.

Breaking: Masked sword-weilding attacker at school in #Sweden dead after being shot by police, media report. 4 kids 1 adult hurt, police say — Carl Fridh Kleberg (@FridhKleberg) October 22, 2015

The school was engulfed in chaos following the incident, with students and teachers crying and in distress, TTELA photographer Stefan Bennhage said, as cited by Norwaegian newspaper Aftonbladet.

#Trollhattan Le suspect ne serait pas mort mais "grièvement blessé" pic.twitter.com/JAr797m1CF — Breaking3zero (@Breaking3zero) October 22, 2015

He described hundreds of people standing around the main street, adding that some were trying to get past the police cordon.

JUST NU: Ett av offren har avlidit efter skoldådet i #Trollhättan, uppger TT. https://t.co/rQLTJx6nVYpic.twitter.com/fZHOV0L15o — Svenska Dagbladet (@SvD) October 22, 2015

Gustaffson said the incident is now over, and the situation in the town is beginning to calm down. He added, however, that family members are still arriving at the school to check on friends and relatives.

2015-10-22 10:10, Misshandel, grov, Trollhättan: Polisen får larm om att maskerad man som gått runt på en skol... https://t.co/i4D2vMP1St — Polisen Västra Götal (@polisen_vg) October 22, 2015

Following the incident, Swedish Teacher's Union president Johanna JaaraAstrand tweeted: “Terrible what happened in Trollhättan! Think of the children, staff and families. All support to them in this unimaginable situation!”

Fruktansvärt det som skett i Trollhättan! Tänker på barnen, personalen och anhöriga. Allt stöd till dem i denna ofattbara situation! — Johanna JaaraÅstrand (@JohannaJAstrand) October 22, 2015

The school is attended by more than 400 children, according to its website. Students range from around age six to 15.

The attack occurred in Kronogården, a disadvantaged area where more than half the population were born abroad.

Researchers have named Trolhättan the most highly segregated city in Sweden, with immigrants concentrated in Kronogården.

Elsewhere in Sweden, a school in the city of Hortlax was cordoned off after a man was seen traveling toward the school on bicycle, wielding an ax.

He was arrested on the spot, Aftonbladet newspaper cited police officer Catrin Hedqvist as saying. She added that an investigation is underway.