SWEDEN has woken up to the prospect of weeks of political uncertainty after the country’s two rival blocs failed to secure a clear governing majority in the general election.

The poll also saw a boost for a far-right party, but with an increase smaller than had been expected.

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

Sunday’s election saw the Sweden Democrats, an anti-immigrant party with roots in a neo-Nazi movement, win about 18%, up from the 13% it gained four years earlier.

The party, which has worked to moderate its image in past years, saw gains amid a backlash against the challenges of integrating hundreds of thousands of immigrants who have arrived in the Scandinavian nation over the past few years.

Prime Minister Stefan Lofven, who brought the Social Democrats to power in 2014, said he intends to remain in the job.

The centre-left party emerged with the greatest share of the vote – 28.4% as the count neared completion – but will probably hold fewer parliamentary seats than four years ago.

The leader of the Moderates party that came in second, Ulf Kristersson, has already called on Lofven to resign and claimed the right to form Sweden’s next government.

Sounding sombre and firm, Lofven told his supporters the election presented “a situation that all responsible parties must deal with,” adding that “a party with roots in Nazism” would “never ever offer anything responsible, but hatred.”

“We have a moral responsibility. We must gather all good forces. We won’t mourn, we will organise ourselves,” he said.

The centre-right, four-party Alliance has said it would meet to discuss how to move forward and demand the resignation of Lofven, head of the minority, two-party governing coalition.

Final election returns are expected later in the week. The preliminary results make it unlikely that any party would secure a majority of 175 seats in the 349-seat Riksdag, Sweden’s parliament.

The potential for an immigration backlash to result in a big boost for the far-right Sweden Democrats inspired fear among many Swedes before the election.

It received a little more than one in six votes, or 17.6%, rising from 12.9% in 2014, but its showing was not as strong as the one-in-five polls had predicted. However, the party’s leader told supporters: “We won.”

With the prospect of weeks or months of coalition talks before the next government is formed, Swedish tabloid Expressen headlined its front page: “Chaos”.

Both the left-leaning bloc led by the Social Democrats and the centre-right bloc have said they would refuse to consider the Sweden Democrats as a coalition partner.

Like other far-right parties in Europe, the Sweden Democrats worked to soften its neo-Nazi image in the lead-up to the election.

The party symbol was switched from a flame thrower to a flower. Members known for making pro-Third Reich statements were pushed out.

It made its first mark in politics with municipal council seats in 2006, and since then slowly helped revise long-accepted social norms for what Swedes could say openly about foreigners and integration without being considered racist.

Sweden has been known for its comparatively open doors to migrants.

Sunday’s general election was the first since Sweden, a population of 10 million, took in a record 163,000 refugees in 2015 – the highest per capita of any European country.

At the Swedish Democrat’s election eve rally on Saturday, party leader Jimmie Akesson criticised Lofven’s government for “prioritising” the needs of new immigrants.

Turnout in the election was at 84.4%, up from 83% in 2014.