A masked man with a sword killed a two people, including a teacher and a student, and injured two others with a sword at a school in city of Trollhatten in Sweden on Thursday before being shot.
Swedish officials said the condition of two of the students was serious.
Police arrived at school after an emergency call saying there was a man wearing a mask and wielding sword in the building who attacked a person in the cafe area of the Kronan school.
"Shortly after this we received information that the assailant had been shot," the police said on their website.
The assailant was then rushed to hospital to receive treatment for his wounds, but died later.
According to Swedish officials 400 students aged between six and 15 were in the school when the masked man entered the building.
Speaking to The Local, one student at the school said, "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."
On Thursday morning, teachers held a meeting over concerns that the school was too not secure enough as adults were able to enter an adjoining cafe, Swedish media said.
Students had to go through the cafe in order to reach the school building and the student's cafeteria.
After the incident, Swedish Prime Minister Stefan Lofven 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 added.
Meanwhile, Sweden's Interior Minister Anders Ygeman wrote on his Twitter account, "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."
Prime Minister Lofven is due to travel to the scene of the attack later on Thursday.