Two further victims are seriously injured.
The attacker was shot by police and is undergoing surgery at a nearby hospital.
Eyewitnesses described chaos at the school, in the western town of Trollhattan, with hundreds of students fleeing from the building screaming.
Police responded to an emergency call reporting an attack in the cafe area of the Kronan school, at around 10:10 local time on October 22.
One teacher died of his wounds at the scene.
Two male students, aged 11 and 15, and another teacher were rushed to hospital.
One of the boys has since died.
A student told Swedish television that initially the pupils thought it was a joke.
“He had a mask and black clothes and a long sword,” the student said.
Another student said the man was wearing a Star Wars mask, Swedish newspaper Dagens Nyheter reports.
Police spokesman Thomas Fuxborg told the Associated Press the attacker was in his 20s and carried more than one weapon, including “at least one knife-like object”.
Thomas Fuxborg said police fired two shots, one of which hit the attacker. No motive was given for the attack.
One student told The Local newspaper: “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. I’m feeling really scared. Everyone’s scared here.”
Sweden’s PM Stefan Lofven will travel to Trollhattan this afternoon. He said it was a “black day for Sweden”.
“I think of the victims and their families, students and staff, and the whole of the affected community. No words can describe what they are going through right now. We must ensure that they receive all the support they need,” he said.
Sweden’s interior minister, Anders Ygeman, tweeted: “It is with sadness and dismay I received the news of the attack on the school in Trollhattan. My thoughts go to the victims and their families.”
Trollhättan is an industrial town in west Sweden, located around 50 miles north of Gothenburg, the country’s second largest city.
School attacks are rare in Sweden – this is the first since a shooting at a school in Kungalv near Gothenburg in 1961 which killed one person and injured six others.
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…
Misleading allegations, rumours and outright lies about voting and fraud are flooding online spaces in…
At least 158 people have died in Spain's worst flooding disaster in generations. On October…
Google has been fined two undecillion (a two followed by 36 zeroes) roubles by a…
Embarking on a home remodel is an exciting journey, promising enhanced comfort, increased property value,…
The US presidential candidates continued to campaign across key swing states on October 20. Footage…