Updated

Sweden has become the latest European country to have its political order shaken by a backlash against large-scale immigration, with voters giving a boost to a far-right party and weakening the more established ones.

Sunday’s election left the two rival blocs — a center-left group and a center-right alliance — with roughly 40 percent of the vote each, portending what is likely to be weeks of uncertainty and complex coalition talks before a new government can be formed.

The Sweden Democrats, which has roots in a neo-Nazi movement but has worked to soften its image, won 17.6 percent, up from 13 percent in 2014, for a third-place finish. That showing is not strong enough for it to lead a government, but it reflects how deeply that Sweden, famous for its progressive policies, is being transformed by migration.

The country that is home to the Nobel prizes and militarily neutral policies for the better part of two centuries has been known for its comparatively open doors to migrants and refugees.

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

That had followed the earlier arrival of hundreds of thousands of asylum seekers.

Since 2015, the center-left government has sharply restricted immigration, but many Swedes complain that society cannot cope with integrating so many newcomers, many of them Muslims from Africa and the Middle East.

The growing strength of the Sweden Democrats also reflects how old taboos are collapsing.

Only a few years ago, Swedes would be shunned as racist for suggesting the country had limits on how many migrants it should take, or for expressing the view that it is hard to integrate Africans and Arabs. But people increasingly are expressing such ideas more freely — adding to the support for the party.

While the result is a boost for the Sweden Democrats, the party fell short of pre-election predictions.

The Expressen tabloid said in editorial that “it all pointed at the Sweden Democrats taking over the position as Sweden’s second-biggest party. But the expected ... bang didn’t happen.”

The election came after populist and anti-migrant parties made significant political gains in Germany, Austria and Italy since 2015 — the other countries that have shouldered the heaviest burden of accommodating those fleeing war and conflict or simply searching for a better life elsewhere.

Sweden also gained international scrutiny after U.S. President Donald Trump portrayed the country as place where multiculturalism has brought crime and insecurity.

In early 2017, Trump claimed that a terrorist attack had happened the previous night in Sweden. The night, in fact, had been quiet, but Trump had seen a Fox News report about crime by immigrants in Sweden. He has insisted that he is still right about the general picture of the country as one where large-scale migration has brought security threats.

That narrative of Sweden as a failed multicultural experiment is also pushed by some on the right in Europe. While some Swedes say there is some truth to that, others feel it is too exaggerated and ignores the fact that Sweden is a place with a strong economy where many things work very well.

Both the left-leaning bloc led by the Social Democrats and the center-right bloc, in which the Moderates is the largest of four parties, have said they would refuse to consider the Sweden Democrats as a coalition partner.

Prime Minister Stefan Lofven, who brought the Social Democrats to power in 2014, said he intended to remain in the job. His party emerged with the greatest share of the vote — 28.4 percent as the count neared completion — yet is looking at holding fewer seats in parliament than four years ago.

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 forces for good. We won’t mourn, we will organize ourselves,” he said.