Sweden is headed for a hung parliament after an election that saw the popularity of the nationalist Sweden Democrats surge, as one of Europe's most liberal nations turns right amid fears over immigration.

Key points: Votes in almost all districts have been counted

Votes in almost all districts have been counted Centre-left and centre-right parties win just over 40 per cent of vote

Centre-left and centre-right parties win just over 40 per cent of vote Sweden Democrats vote rises to nearly 18 per cent

With votes in all but two of 6004 districts counted, preliminary results suggested no party or bloc would win a majority and there was no clear answer to which parties would be able to govern without support from the anti-immigration Sweden Democrat party.

Far-right parties have made spectacular gains throughout Europe in recent years amid growing anxiety over national identity and the effects of globalisation and immigration following armed conflict in the Middle East and North Africa.

In Sweden, an influx of 163,000 asylum seekers in 2015 — the most in Europe relative to the country's population of 10 million — has polarised voters and fractured the political consensus.

With almost all districts having reported, the ruling centre-left Social Democrats and Greens and their Left Party parliamentary allies had 41.6 per cent of the vote, while the opposition centre-right Alliance was at 40.9 per cent.

That gave the centre-left 144 seats in the 349-seat Parliament against 143 for the Alliance, suggesting weeks of uncertainty before a workable government can be formed.

The Sweden Democrats, a party with roots in the white supremacist fringe, won 62 seats, up from 49 seats in the last election four years ago, the biggest gain by any party in Sweden's parliament, the Riksdag.

Social Democratic Party leader and Prime Minister Stefan Lofven arrives with his wife Ulla to cast their votes in Stockholm. ( AP: Soren Andersson/TT )

While the results fell short of leader Jimmie Akesson's predictions of 20 per cent of the vote or more, he told a party rally it was nevertheless the winner of the election.

"We will gain huge influence over what happens in Sweden during the coming weeks, months and years," Mr Akesson told party colleagues.

Mr 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.

He challenged Ulf Kristersson, the centre-right Alliance's candidate for the premiership, to choose between seeking support from the Sweden Democrats and the incumbent Social Democrat Prime Minister Stefan Lofven.

Most of the votes have now been counted. ( AP: Johan Nilsson/TT )

Mr Kristersson called on Mr Lofven to resign, but rebuffed Mr Akesson.

"We have been completely clear during the whole election. The Alliance will not govern or discuss how to form a government with the Sweden Democrats," he said.

Mr Lofven said he would not resign and called for cross-party cooperation to resolve the political impasse.

"There is no side with a majority. Then it is only natural to work across the political divide to make it possible to govern Sweden," Mr Lofven said.

Growing chorus of euroscepticism

People head to the polls on election day in Stockholm. ( AP: Hanna Franzen/TT )

The election will add to concerns in Brussels as the European Union enters campaign mode ahead of the European Parliament election in May, which could give more voice to eurosceptic groups and thwart efforts at closer EU integration.

The record levels of asylum seekers in 2015 magnified worries about a welfare system that many voters already believe is in crisis, even though refugee numbers have fallen sharply since then.

Lengthening queues for critical operations, shortages of doctors and teachers and the failures of police to deal with inner-city gang violence have shaken faith in the "Swedish model", built on a promise of comprehensive welfare and social inclusion.

Mr Akesson had labelled the vote a choice between immigration and welfare in a campaign that was unusually antagonistic.

Mr Lofven could hold onto power unless the Alliance accepts some kind of support from the Sweden Democrats, at a likely cost of the populists having more say over immigration policy.

But he would need to overcome decades of acrimony between the two blocs and get support from parties on the centre-right, something they have ruled out.

Reuters