GOTEBORG, Sweden -- A knife-wielding masked man stabbed four people Thursday at a school in southern Sweden, killing a teacher and a student before being shot dead by police, authorities said. One student thought the man had something to do with Halloween.

Students fled from the Kronan school in Trollhattan, near Goteborg, Sweden's second-largest city, as the attack took place in a nearby cafe just after 10 a.m., police said. The school has 400 students ranging from pre-school to high school.

Police arrived to find one male teacher already dead and three other people seriously wounded - two male students aged 11 and 15 and another male teacher, police spokesman Thomas Fuxborg told The Associated Press. Police fired two shots, one of which hit the attacker, he said.

One student and the attacker died later at the hospital, authorities said.

The attacker, a 21-year-old from Trollhattan, knocked on the doors to two classrooms and stabbed those who opened them, police spokesman Thord Haraldsson told a press conference. He said the man had "sharp stabbing weapons," which another police official told the AP may have included a sword.

Police searched the attacker's home and found "interesting" things, Haraldsson added, without elaborating.

Police spokesman Stefan Gustavsson said authorities knew the attacker had killed the teacher "because of the wounds he had."

Laith Alazze, a 14 year-old student at Kronan, said at first he thought the attacker - who was clad in black and wearing a mask - had something to do with Halloween.

"One of my friends walked over to him to challenge him, but when we saw he stabbed him (the teacher), we ran away," Alazze told Sweden's TV4.

The attacker had gunshot wounds 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.

The three wounded, all in serious condition, underwent surgery at the Norra Alvsborgs Lanssjukhus hospital. Dr. Lars Spetz told reporters the teacher had been stabbed in the abdomen while the two students were stabbed in the abdomen, liver and chest.

"They hover between life and death," Spetz said.

Swedish media said the school held a meeting Thursday morning to discuss teachers' fears that they could not control access to the school. The Dagens Nyheter newspaper said students must go through a public cafe to reach the school's cafeteria and other parts of the building.

Swedish Prime Minister Stefan Lofven, who went to the scene, described Thursday as a "black day."

"My thoughts go out to the victims and their families, the students and staff, and the whole community that has been affected," Lofven said. "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." null