A masked sword-wielding man has killed at least two people and wounded some others at a school in Sweden before being shot by police on Thursday, authorities said.

One male teacher, 20, died following the incident, along with a pupil, whose age was confirmed by police in the evening as 17.

The attacker broke into a school for children and teens aged between six and 15 in the southwestern town of Trollhattan, near Goteborg, Sweden’s second-largest city, on Thursday morning.

“One of the four people brought to hospital has died,” Nicklas Claesson, a hospital spokesman, said. Swedish media reports said the fatality was a young male student.

Another teacher and two boys, aged 11 and 15, were also seriously wounded.

“The assailant knocked on two classroom doors and he attacked the two students who opened the doors,” police investigator Thord Haraldsson told a press conference in Trollhättan.

He said that officers called to the scene had fired two shots, with one of them hitting the assailant, after the suspect had first attempted to attack the police.

Haraldsson said if the police hadn’t reacted as quickly as they did, the situation could have been much worse. Pre-school children had been visiting the school’s library earlier in the day.

Some pupils have described how they initially thought the man’s appearance was a prank.

“When we first saw him, we thought it was a joke. He was wearing a mask and black clothes and (carrying) a long sword Some students wanted to take their picture with him and feel the sword,” one unidentified pupil told.

No information has been disclosed about the masked man, while his motive behind the attack was not immediately clear.

Eyewitnesses described chaos at the school, with hundreds of students fleeing from the building screaming.

“It is a terrible tragedy, and the people are very anxious,” a police spokesman told media.

Swedish police officers speak to members of the public as they secure the area outside the school Photo: AFP/Getty Images

Swedish police officers speak to members of the public as they secure the area outside the school Photo: AFP/Getty Images