The attack took place in the southwestern town of Trollhattan at a school for children aged between six and 15.
"One teacher has died at the scene," local health officials said, indicating that another teacher and two boys, aged 11 and 15, were also wounded in the assault.
It was not immediately clear how badly they were hurt.
Police said they shot the assailant at the scene but did not immediately confirm his condition. The man, who was reportedly in his 20s, was taken to hospital for treatment.
More From This Section
Media reports said the assailant was wearing a Star Wars mask, and school children initially thought it 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 student told news agency TT.
When the man started attacking people, he quickly realised it wasn't a joke and fled as the assailant went from classroom to classroom looking for victims.
Police said there was "a lot of confusion" at the school, saying there were still pupils and teachers inside more than two hours after the attack.
According to its website, the Kronan school has around 400 pupils, including many newly-arrived immigrants.
Swedish media described it as a "problem school".
It had been criticised by the Swedish Schools Inspectorate for its lax security and on account of a number of disruptions which prevented the pupils from learning.
Teachers had complained to the inspectorate about the school library and cafe being open to the public and creating an insecure environment for the children, TT reported.