Claus Forberg, 76, who serves on the city council in Kragerø, southern Norway, resigned from the party on Monday.
Forberg on Friday wrote on a closed Facebook page that he “could almost understand that Swedish fool who ran amok at school with a sword.” He added that he had only called the Swedish killer "a fool" because he had worn a mask.
The apparent approval of the attack by 21-year-old Swede Anton Lundin Pettersson, which left a 21-year-old teaching assistant and a 15-year-old student dead, was immediately condemned by his own party.
Torleif Fluer Vikre, the party's leader in the municipality, who on Friday called Forberg's statement "totally unacceptable" said he was happy he had now stepped down.
"This is absolutely correct," he said. "The matter is now closed."
Lundin Pettersson, a computer gamer who dressed only in black or camouflaged clothes, died on Thursday after being shot by police at the end of his attack.
According to Swedish police, he selected his victims by skin colour.
Norway's Prime Minister Erna Solberg also said it was “totally unacceptable” for politicians to give any support to violence.
“It is legitimate to discuss politics and express the worries many have, but it is not legitimate to incite violence or give support to violence,” she said.
But Forberg was initially unapologetic, arguing that the failure of governments in Sweden and Norway to control immigration from Muslim countries was forcing people to take drastic action.
He blamed “the politics that are conducted in Norway in Sweden,” where “people give in to Muslims” for the attack.
“Muslims are in the process of changing Norwegian society,” he wrote.
He told Norway's ABC news that he himself thought of carrying out similar attacks.
"I can also fantasize about taking the lives of some Arabs," he said.
Only later, when he realized the extent of the opposition his remarks had triggered, did he admit any fault.
“I am sorry that I wrote it [the comment] and that it has been perceived that way,” he said. “It's not me who has called for it [the attack], and I would not encourage anyone to do it either,” he said.
Forberg made his remarks on the “Stop extreme mass immigration” Facebook group, which is only visible to members.
Swedish police on Friday confirmed that Anton Lundin Pettersson's attack was a “hate crime” with victims selected on the basis of their skin colour.
As well as killing two people, the 21-year-old wounded three others before he was shot by Swedish police.