The 17.7% of the vote the Social Democrats received gives it 40 of the 200 seats in Finland's new parliament, one more than the 39 the euroskeptic, anti-immigration Finns Party secured with its 17.5% support.
"I have to make a honest confession: I hoped still for a better result," Social Democratic Party leader Antti Rinne, a former finance minister and union leader, told supporters in central Helsinki. "Let us, my friends, take the Finnish society toward sustainable climate, social and economic policies."
Sunday's election had been watched for signs of how a bloc of euroskeptic populists might do in next month's European Parliament elections. The Finns Party is part of an alliance that hopes to become the strongest faction in the European Union legislature and to radically transform EU policies on migration, families and the environment.
Finns Party chairman Jussi Halla-aho, who received the most votes by far of any candidate for the Eduskunta legislature, said he was surprised by his party's strong performance. "I certainly could never have expected a result like this," an elated Halla-aho said. Honestly speaking, none of us expected this kind of result."
Voters chose between 2,500 candidates from 19 political parties and movements. Preliminary returns showed the conservative National Coalition Party in third place with 37 seats and outgoing Prime Minister Juha Sipila's Center Party claiming 31 places in the legislature.
The Center Party lost more support than any other party compared to Finland's last election in 2015, apparently punished by voters for failing while in government to push through an ambitious health care and social care reform plan.
Finnish Institute of International Affairs program director Mika Aaltola said voters putting their support behind comparative political upstarts produced "a historic result" in Finland that reflects disenchantment with mainstream politics across Europe.
"Support for the three traditional established parties has been down for years. The political center is weakening, which is an overall European phenomenon," Aaltola wrote on Twitter. After an election, the party that attracts the most votes typically tries to a new government with other parties as partners. A Cabinet made up of ministers from different political parties is a long-time tradition in Finland.
Most political observers said the election's outcome means if Rinne is named prime minister-designate, he likely would try to form a broad-based majority government with the National Coalition party or a combination of the Center Party and smaller parties such as the Greens.
Rinne said after casting his ballot that all coalition options remained on the table if his party won the most votes but that Finland's government needed to have "the same value base." The election followed a campaign in which concerns about climate change even overshadowed the issue of how to reform the nation's generous welfare model.
Finland, a European Union member of 5.5 million people, has one-third of its territory above the Arctic Circle. Most political parties support government actions to curb global warming. Pre-election debates over what and how much the Nordic country should do revealed disagreement among voters. The Finns Party railed against public sacrifices in the name of fighting climate change. It put less focus on immigration than anti-migrant, euroskeptic counterparts elsewhere in Europe have done in recent years.
"For everybody, it's about the climate. It's kind of a climate election. Everybody's feeling some kind of a depression about it," voter Sofia Frantsi, 27, an interior architect from Helsinki, said Sunday.
Rural voters and other residents who feel that the climate change plans of other leading parties require too much sacrifice have been part of the momentum of the populist Finns Party. "We want a more moderate and sensible climate policy that does not chase industries away from Finland to countries like China," Halla-aho said Sunday at a Helsinki polling station.
Immigration remains a key policy issue, Halla-aho said. Greenpeace Finland called Sunday's vote the "climate election," saying that "never before has climate and the limits of planet Earth been discussed with such seriousness in Finland."
The environmental group cited a recent nationwide poll in which 70% of respondents said tackling climate change and reducing carbon footprints should be key priorities of the new government. Finland is boosting its production of nuclear energy by launching a new nuclear power plant next year. Finnish lawmakers last month voted to phase out burning coal as an energy source to end it by 2029.
Other proposals include increasing the number of electric vehicles on Finland's roads and reducing meat consumption through taxes or serving more vegetarian food as part of publicly funded meals in places like schools and the military.
The Social Democratic Party, which has traditionally attracted working-class voters, favors raising taxes and increasing spending to overhaul the social and health care system, which is under strain with one of the most rapidly aging populations worldwide.
The Social Democrats also back the pro-European Union policies of Finland, which uses the shared euro currency but is not a NATO member. Finland shares a 1,340-kilometer (830-mile) border with Russia.
Negotiations to form the next government "will be very difficult, that's very clear, before they can create a government," said Jukka Vakkila, a 57-year-old doctor from Helsinki. "But I think that they will find some kind of consensus ... Finland could be a good example for other countries in this way."
Olli Kangas contributed from Helsinki. Vanessa Gera contributed from Warsaw.