Masked man armed with sword in western town of Trollhattan kills teacher and student, before being shot dead.

A teacher and a student have been killed and several others injured in a stabbing attack at a school in Sweden, according to police.

A masked man armed with a sword entered the school in the western town of Trollhattan on Thursday morning, slashing several people.

The student died in hospital, while the teacher, a male, was pronounced dead on scene.

Two other students and a teacher underwent surgery after the attack, medical officials said.

The attacker had a gunshot wound to his lower chest and died later Thursday at the hospital, officials said. Police spokeswoman Maria Randsalu said the second victim was a student, but did not say which one.

One witness, a student at the school, told broadcaster SVT that the attack was initially believed to be a joke.

“He wore a mask and black clothes. There were students asking to take pictures with him and touch the sword,” the student said.

‘A tragedy’

Swedish Prime Minister Stefan Lofven called the deadly stabbing attack “a tragedy that hits the entire country.” He spoke outside the school in Trollhattan after viewing the lobby where the attack began.

Lofven declined to comment on Swedish press reports that the attacker had right-wing sympathies, saying police were still trying to establish a profile of him.

“My thoughts go out to the victims and their families, the students and staff, and the whole community,” Lofven said earlier. “No words can describe what they are going through right now.”

King Carl XVI Gustaf said Sweden was “in shock” following the attack and that the royal family received the news “with great dismay and sadness.”

In August, a knife attack in an IKEA store in the central city of Vasteras left a mother and a son dead.