Denmark's Liberal Prime Minister Lars Lokke Rasmussen has conceded victory in the country's general election, paving the way for Social Democrat leader Mette Frederiksen to take power.
"We had a really good election, but there will be a change of government," the prime minister told supporters.
The Social Democrats won 91 of the 179 seats in parliament.
At 41, Ms Frederiksen is set to be the country's youngest ever prime minister.
The general election was dominated by debates over climate change, welfare cuts and immigration.
Mr Rasmussen's Liberal Party has been in power for 14 of the last 18 years.
The exit polls suggested that support for the far-right Danish People's Party (DF) had more than halved since the last election in 2015.
The party has offered its support to successive right-wing governments over the past two decades in exchange for stricter policies on immigration.
But with major parties, including the Social Democrats, adopting restrictive immigration policies in this election, observers say the DF has lost its unique appeal.
Denmark is to become the third Nordic country in a year to elect a leftist government, following Sweden and Finland.