STOCKHOLM — Swedish riot police briefly clashed with counterdemonstrators at a neo-Nazi rally in Stockholm on Saturday, two weeks before a parliamentary election.

Police said four police officers and three civilians were slightly injured in the violence that erupted on the sidelines of a march by about 150 members of the far-right Party of the Swedes.

Thousands of people gathered in Stockholm to protest peacefully against the march, but a few dozen masked activists attacked police with firecrackers, bottles, eggs and panels from a security fence.

Lars Bystrom, police spokesman, said one was arrested for “preparation for aggravated assault,” and another was arrested for trespassing after climbing onto the roof of the Royal Opera, outside which the neo-Nazis started and ended their march.