The attacker who stabbed two people to death at a school in Sweden before being shot and killed by police had a racist motive, police said on Friday. Police labelled the stabbing in the industrial town of Trollhattan a hate crime based on discoveries they made when searching the man’s home, the way he dressed, his behaviour at the scene and the way he selected his victims. “All together, this gives a picture that the perpetrator had a racist motive when he committed the crimes at Kronan school,” police said. The 21-year-old masked man, who has not been identified by police, entered the school in southern Sweden on Thursday and stabbed four people , two of whom died, before he was shot by police. He later died of his wounds. Police said they had seized a car that the attacker could have used but declined to comment on a report in local tabloid GP that some kind of suicide note had been found. The attack stunned Sweden, where violent crime is relatively rare, though there has been a recent spate of arson attacks on asylum centres in the south of the country as the influx of refugees has surged. Immigration officials estimate that some 190,000 will arrive this year, second only to Germany in western Europe. “This is a black day for Sweden,” Prime Minister Stefan Lofven said of the attack, the deadliest ever to target a school in Sweden. “It is a tragedy that hits the entire country.” According to Swedish media, the assailant posed for photos with students before beginning his deadly rampage in the halls of the Kronan school in Trollhattan, which has a large immigrant community. A majority of the students at Kronan are foreign-born. Many students thought the attacker was playing a Halloween prank. News outlets posted a photo of a black-clad man they identified as the attacker wearing a military-style helmet and a black mask with a sword in his hand. Panicked students fled the school, as police and ambulances rushed in. They found a dead male teacher and three people seriously wounded — two boys, aged 11 and 15, and another male teacher. One of the students later died of his wounds. None of the victims had been identified. The condition of the 15-year-old victim had improved and his state was considered stable, said Ulrika Jisland, a spokeswoman for the Norra Alvsborgs Lanssjukhus hospital. She said the 41-year-old teacher was considered to be in a “serious but stable” condition. Officers fired two shots, hitting the attacker with a bullet in the lower chest, and he later died at a hospital. Police said the assailant had entered the school through a cafe in its lobby that was open to the public, then knocked on the doors of two classrooms, stabbing his victims. Late on Thursday, dozens of people gathered quietly to pay their respects outside the school, whose roughly 400 pupils range in age from pre-school to high school. Sweden's last school attack was in 1961, when a 17-year-old man opened fire at a school dance hall in the southwestern part of the country, wounding seven students, one of whom died later. Violent crime is rare in the country, which has strict gun-control laws. In 2013, there were 87 homicides reported in Sweden, a country of some 10 million people.