STOCKHOLM — Sweden looked set for a period of political confusion after election results on Sunday put a center-right bloc and the governing center-left coalition neck and neck, while a far-right, anti-immigration party came in third — winning a higher percentage of the vote than ever before, but achieving less of a breakthrough than polls had suggested.

With more than 99 percent of ballots counted, the national election commission reported that the governing center-left Social Democrats had 28.4 percent of the vote, making it the largest single vote-getter, but handing the party its worst showing in decades.

The center-right Moderate party was next at 19.8 percent, while the far-right Sweden Democrats were running third, with 17.6 percent, up from 12.9 percent in 2014 but a less successful showing than many Swedes had feared. Some polls had predicted that the Sweden Democrats would come in second, with more than 20 percent of the vote.

The red-green bloc of center-left, leftist and environmental parties, led by the Social Democrats, had 40.6 percent of the vote. The center-right alliance, led by the Moderates, was just behind with 40.3 percent. The results mean neither bloc can command a majority in Parliament, and both have rejected the idea of any deal with the Sweden Democrats.