Sweden faces a protracted period of political uncertainty after an election that left the two main parliamentary blocs tied but well short of a majority, and the far-right Sweden Democrats promising to wield “real influence” in parliament despite making more modest gains than many had predicted.

The populist, anti-immigrant party won 17.6% of the vote, according to preliminary official results – well up on the 12.9% it scored in 2014, but far below the 25%-plus some polls had predicted earlier in the summer. It looked highly likely, however, to have a significant role in policymaking.

The governing Social Democrats, led by prime minister Stefan Löfven, maintained their record of finishing first in every election since 1917, but saw their score fall to 28.4%, the lowest for a century, while the main centre-right opposition Moderate party also slipped to 19.8%.

On a broadly favourable night for the smaller parties, the ex-communist Left and the the centre-right Centre and Christian Democrat parties all advanced. Crucially for the centre-left’s chances of forming a government, the Green party scraped over the threshold for parliamentary representation with 4.4%.

But the new government, which could now take weeks to form, will need either cross-bloc alliances between centre-right and centre-left parties, or an accommodation with the Sweden Democrats – long shunned by all other parties because of their extremist roots – to pass legislation, potentially giving the populists a say in policy.

With the centre-left bloc on 40.6% of the vote and the centre-right on 40.2%, analysts predict long and complicated negotiations will now be needed to build a majority, or – more likely – a minority that will not easily be sunk. This looks difficult on the left, where any coalition would need to include the ex-communist Left, effectively excluding cooperation from the centre-right.

Many observers therefore see the Moderate party leader, Ulf Kristersson – who on Sunday night called for Löfven to resign – seeking to form a minority centre-right administration, possibly in coalition with the Christian Democrats and with implicit, ad hoc parliamentary support from the Sweden Democrats.

This would give the populist party the opportunity to influence policy, particularly on immigration, in exchange for votes.

Löfven said he would not be resigning, and urged cross-bloc cooperation: “The Sweden Democrats can never, and will never, offer anything that will help society. They will only increase division and hate.” The mainstream parties now had a “moral responsibility” to form a government, he said.

Addressing supporters on Sunday night, the Sweden Democrats’ leader, Jimmie Åkesson, said the 63 seats it would have in the 349-seat Riksdag represented victory. “No one can take that away from us.”

He said he was interested in cooperating with the other parties, and wanted to tell the Moderates in particular “how to govern the country … We strengthen our kingmaker role. We will have an immense influence over what happens in Sweden in the coming weeks, months, years.”

Both the smaller Liberal and Centre parties in the Moderates’ current centre-right alliance are fiercely opposed to any normalisation of relations with the populists, as are all the parties on the left.

The election was Sweden’s first since the government allowed 163,000 migrants into the country – the most per capita of any European nation – during Europe’s 2015 migration crisis, polarising the nation’s 7.3 million voters and magnifying popular concern about a welfare system many felt was already under strain.

Long waits for operations, shortages of doctors and teachers and a police force that has had difficulties dealing with a spate of gangland shootings and grenade attacks – often in deprived areas with high concentrations of immigrants – have all shaken faith in Sweden’s prized model of generous welfare and inclusiveness.

The often antagonistic campaign was largely dominated by themes of immigration, integration and welfare, with the Sweden Democrats repeatedly presenting the vote as a straight choice between immigration and welfare spending.

“This government we have had ... have prioritised, during these four years, asylum-seekers,” Jimmie Åkesson, the far-right party’s leader, told his final election rally this weekend. “Sweden needs breathing space. We need tight responsible immigration policies.”

The Tories are long-time allies of far-right Swedes | Letters Read more

Casting his ballot in Stockholm on Sunday, Löfven, whose government radically tightened immigration laws in 2015, also described the vote as “a referendum about our welfare”. But, he said: “It is also about decency, about a decent democracy ... and about not letting the Sweden Democrats, an extremist party, a racist party, get any influence in the government.”

Far-right parties have made significant gains at the expense of the political mainstream across western Europe in recent years in the aftermath of the 2008 global financial crisis and the 2015 refugee crisis, and are now in government in Italy, Austria, Norway and Finland.

“Traditional parties have failed to respond to the sense of discontent that exists,” said Magnus Blomgren of Umea University. “That discontent maybe isn’t directly related to unemployment or the economy, but simply a loss of faith in the political system. Sweden isn’t alone in this.”