A sword-wielding man reportedly attacked students and teachers at a school in Sweden's Trollhattan city on Thursday, leaving two dead - a teacher and a student.

The attacker himself succumbed to injuries in a hospital after being shot by the police. The 21-year-old was shot in the chest.

A masked man was seen near the school walking with a sword, according to a statement by the Sweden police. Swedish news agency TT reported that a hospital has confirmed the death of one of the victims of the sword attack. Two students aged 11 and 15 have been seriously injured.

A police spokesperson called the attack 'one of the most serious incidents in Sweden's history'. 

"This is a black day for Sweden," said Prime Minister Stefan Lofven, who rushed to Trollhattan, a town of around 50,000 people. "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," USA Today quoted him as saying.

In a statement, Sweden's King Carl XVI Gustaf said the royal family had received the news "with great dismay and sadness" and that the country was 'in shock'.

Photos from the scene of the attack were shared on Twitter.