Anti-immigrant far-right holds balance of power as Stefan Löfven prepares for coalition talks with Greens and other parties

Sweden's Social Democratic party, which on Sunday ended its longest spell in opposition in a century, faces a weak minority government after the far-right Sweden Democrats emerged as the third-largest party.

In his first speech after the election result, the incoming prime minister, Stefan Löfven, a former welder who built his career in the country's union movement, expressed his conviction thatinsisted the new government would be functional. "I am ready to form a workable government for Sweden," he said. "The Swedish people have turned their backs against tax cuts and privatisations. The Swedish people demanded change."

Mariam Ismail Egal, a Social Democrat activist in Malmö, where 40% of people are from an immigrant background, said many in the city were "disappointed and frightened" that the Sweden Democrats had doubled their vote to more than 13%.

"I think we are becoming more like France, and I think we will see a lot of conflict and division in our society," she said.

Jimmie Åkesson, the party's leader, was jubilant as preliminary vote counts came in. "We're the absolute kingmaker now," he said. "They can't ignore us the way they have ignored us over the past four years."

With more than 80% of the vote counted, the three main left-of-centre parties had won 43.7%, comfortably more than the centre-right Alliance's 35.3%, but still far short of a majority.

Löfven, who had not previously been elected to public office, struggled against more experienced opponents in the country's eight televised election debates. But his years of backroom union negotiations will be invaluable in forming a government strong enough get the country's budget through parliament in November.

In his victory speech, Löfven ruled out any cooperation with the Sweden Democrats, which, despite the efforts of Åkesson to rebrand it as a non-racist party, has its roots in the Swedish Nazi movement.

"Remember, 87% of Sweden didn't vote for them," he said to the cheers of the activists and journalists gathered at the victory party. "Even if the Sweden Democrats had even higher numbers, we would not cooperate."

Löfven hinted instead at deals with the two smaller parties in the country's rightwing alliance, whose combined 11.5% share would bring them close to a majority.