Police chief Niclas Hallgren said they had based their conclusion on what was found at the killer’s apartment and “his behavior during the act”.
According to media reports, the 21-year-old attacker had far-right sympathies.
Armed with a sword and wearing a helmet and mask, the man stormed a school in Trollhattan, near Gothenburg, before being shot dead by police.
“We can confirm that this was a racially motivated hate crime partially because the man chose his victims based on the color of their skin,” Niclas Hallgren told Swedish Radio.
The helmet he wore was similar to German World War Two soldiers’ helmets.
He was seen posing for a photograph with students, who thought he was dressed for Halloween, before going from classroom to classroom at the Kronan School.
A teacher and 17-year-old boy died from stab wounds, while another male student, 15, and 41-year-old teacher remain in serious condition in hospital.
The attacker’s name has not yet been released by police, though they say he was local to Trollhattan. He did not have a criminal record, police say.
However, the Swedish daily Expressen and other Swedish media named him as Anton Lundin Pettersson, aged 21.
The young man had allegedly joined a campaign to push for a referendum on whether Sweden should continue accepting migrants.
Sweden has reacted with shock to the killings. Before visiting the scene of the attack, Swedish PM Stefan Lofven said it was a “black day” for the country.
“School is supposed to be the place for learning, play and curiosity and friendship and therefore this is a tragedy that affects the whole country,” Stefan Lofven told reporters.
King Carl Gustaf of Sweden said he was “in shock” and that he had learned of the events in Trollhattan “with great dismay and sorrow”.
Dozens of people gathered outside the school building on October 22 to pay their respects to the victims and place flowers and candles on the ground.
Some residents of the town who were holding a vigil held up posters that read “why kill?”
Swedish media reports say the suspect’s accounts on Facebook and YouTube suggest he had an interest in Hitler and Nazi Germany, as well as hostility to Islam and immigration.
“He was a loner. He played video games, lived in his own world,” a former classmate told Expressen.
Eyewitnesses described scenes of chaos, with the attacker knocking on the doors of at least two classrooms and attacking two male students who opened them. One of the boys later succumbed to his injuries.
None of the victims have been identified by police.
Police were alerted to the attack at around 10:10 local time on October 22, and later gunned down the attacker in the hallway outside a classroom.
The Kronan school has about 400 students aged between six and 15, including many children of immigrants.
Trollhattan is an industrial town in west Sweden, located about 50 miles north of Gothenburg, the nation’s second largest city.
School attacks are rare in Sweden – with just one incident on record in the past 20 years, in which one student was shot dead.
The US House Ethics Committee has voted to release its report on former Republican Representative…
ABC News has agreed to pay $15 million to President-elect Donald Trump to settle a…
South Korea’s parliament has voted to impeach President Yoon Suk Yeol over his failed attempt…
Israeli war planes have carried out more than 100 air strikes in Syria on December…
President-elect Donald Trump has threatened to impose 100% tariffs on the BRICS countries if they…
Syrian troops have withdrawn from the city of Aleppo following an offensive by rebels opposed…