Opposition leader Mette Frederiksen of The Danish Social Democrats appears following preliminary results at Christiansborg Castle in Copenhagen, Denmark Wednesday, June 5, 2019. The Social Democrats emerged as Denmark's biggest party in elections Wednesday, with preliminary results indicating gains for left-leaning parties and a big loss for populists. (Liselotte Sabroe/Ritzau Scanpix via AP)

COPENHAGEN, Denmark (AP) — The Social Democrats emerged as Denmark's biggest party in elections Wednesday, with preliminary results indicating gains for left-leaning parties and a big loss for populists.

If confirmed in final returns, the outcome pointed to the Social Democrats returning to power after four years as the country's leading opposition party.

The Social Democrats got about 25.9% of the votes after a campaign in which party leaders vowed a tough stance against immigration.

Mette Frederiksen, the party's leader, said late Wednesday that the Social Democrats will try to govern as a minority rather than form a governing coalition with smaller parties. It will seek support from the right on some issues, such as immigration, and from the left on other matters, such as social welfare, she said.

Although Frederiksen won't try to form a coalition, other left-leaning parties that increased their vote shares will likely support her effort to form a government to avoid the center-right from getting a chance. The Social Democrats and other left-of-center parties appear headed to having one more vote than a majority in the 179-seat parliament, the Folketing.

With nearly 100 percent of the votes counted, the Liberal Party of Prime Minister Lars Loekke Rasmussen showed a slight gain from four years ago. But the populist Danish People's Party, which often voted with the center-right Liberals, was hit with a big drop in support, meaning Loekke Rasmussen can no longer muster a majority in parliament.

The Danish People's Party's performance was a contrast to some other European countries, where far-right populists have been on the rise. The party was the second-largest party in the outgoing parliament, but its vote share plunged to about 9% Wednesday, compared to 21.1% in 2015.

Loekke Rasmussen conceded defeat and would resign Thursday.

"You have chosen that Denmark should have a new majority, that Denmark should take a new direction," Frederiksen said told a jubilant crowd at parliament. "And you have chosen that Denmark should have a new government."

At age 41, Frederiksen could become Denmark's youngest-ever prime minister.

"The election campaign is now over. It's time to find solutions," she said.

Many Danish People's Party voters have drifted to the Social Democrats, mainly because of it readopting tough views on immigration. The party advocated restricting immigrants in the 1980s and 1990s but softened its position later while in a coalition with left-wing parties.

Its lawmakers voted for several laws introduced by Loekke Rasmussen's government to tighten immigration.

"This is really, really bad," People's Party leader Kristian Thulesen Dahl said of his loss at the polls, but he said the party would not change its politics.

The Hardliner Course party didn't cross the 2% threshold needed to enter Parliament. The New Right, another openly anti-Muslim group that also fielded candidates for the first time, will be in the legislature after getting 2.4% of the votes.

___

This story has been corrected to show that the name of leader of the Danish People's Party is spelled Kristian Thulesen Dahl.

Opposition leader Mette Frederiksen, right, of The Danish Social Democrats reacts following preliminary results at Christiansborg Castle in Copenhagen, Denmark Wednesday, June 5, 2019. The Social Democrats emerged as Denmark's biggest party in elections Wednesday, with preliminary results indicating gains for left-leaning parties and a big loss for populists. (Mads Claus Rasmussen/Ritzau Scanpix via AP)
Danish Prime Minister Lars Loekke Rasmussen of The Liberal Party reacts to preliminary results at Christiansborg Castle in Copenhagen, Denmark during the Parliamentary Elections Wednesday, June 5, 2019. Loekke Rasmussen conceded defeat and would resign Thursday. (Mads Claus Rasmussen/Ritzau Scanpix via AP)
Ballots are counted after the polling stations closed in Copenhagen City Hall, Denmark, on the final day of the parliamentary elections in Denmark, Wednesday June 5, 2019. Denmark is holding a general election and unlike in other European countries, far-right populists don't seem to be on the rise here. The center-left Danish Social Democrats, in fact, may be making a comeback after four years in opposition. (Uffe Weng/Ritzau Scanpix via AP)
Voters wait in line at a polling station in Odense, Denmark, during the general elections on Wednesday June 5, 2019. (Tim Kildeborg Jensen/RitzauScanpix via AP)
Children accompany their parents in the voting booth during voting at Sundby Idraetspark polling station in Copenhagen, Denmark, during the general elections on Wednesday June 5, 2019. (Martin Sylvest/Ritzau Scanpix via AP)
Kristian Thulesen Dahl, leader of The Danish People's Party, receives a ballot at his local polling station in Thyregod, Denmark, during the general elections on Wednesday, June 5, 2019. (Claus Fisker/Ritzau Scanpix via AP)
Danish Minister of Justice and leader of The Conservative Party, Soeren Pape Poulsen, cast his vote at a polling station in Copenhagen, Denmark, Wednesday June 5, 2019, during parliamentary elections. (Bo Amstrup / Ritzau Scanpix via AP)
Rasmus Paludan, leader of Danish right wing party Stram Kurs, arrives to cast his vote during the parliamentary elections in Copenhagen, Denmark, Wednesday June 5, 2019. (Henning Bagger/Ritzau via AP)
A woman and two children enter the voting booth in Copenhagen during the Danish Parliamentary Election 2019 ON Wednesday 5 June 2019. (Liselotte Sabroe/Ritzau Scanpix via AP)