STOCKHOLM — Sweden is facing weeks of political uncertainty after the country's two rival blocs failed to secure a governing majority in elections that saw a boost for a far-right party amid growing discontent with large-scale immigration.

With most of the ballots counted, the governing center-left bloc has a razor-thin edge over the center-right opposition Alliance, with roughly 40 percent each.

Sunday's election saw the Sweden Democrats, an anti-immigrant party with roots in a neo-Nazi movement, win about 18 percent, up from the 13 percent it achieved four years ago. Neither bloc wants to deal with the party.

The Sweden Democrats' gains underscored a broader shift to the right in one of Europe's most socially progressive nations.

Their success follow a rise in popularity for other far-right parties in Europe amid growing anxiety over national identity, the effects of globalization and fears over immigration.

Senior figures in the mainstream parties were expected to meet later on Monday to begin producing a strategy for forming a government. But the process could take weeks and possibly fail, with the Sweden Democrats vowing to sink any Cabinet that doesn't give them a say in policy.

"We will gain huge influence over what happens in Sweden during the coming weeks, months and years," party leader Jimmie Akesson told supporters on Sunday night.

Akesson hopes his party, which wants Sweden to leave the European Union and freeze immigration, can play a decisive role in negotiations over forming a government.

A new election will be called if parliament doesn't agree on a prime minister after four attempts.