Danish Prime Minister Helle Thorning-Schmidt has conceded defeat in the country's general election and has stood down as Social Democratic Party leader.
Her centre-left coalition lost its parliamentary majority after the anti-immigration Danish People's Party made big gains.
Opposition leader Lars Lokke Rasmussen, whose Venstre party won 34 seats, said he would try to form a government.
However, he is likely to have to make big concessions to ensure support from the right-wing Danish People's Party (DF), which ended up with more seats than Venstre, with a total of 37.
With all of the votes counted on the mainland, the parties on the right won 90 seats in parliament, to 85 seats for the left-leaning bloc of Ms Thorning-Schmidt.
DF, now the second-biggest party behind Ms Thorning-Schmidt's Social Democrats, has supported the Liberals in government before and its backing would give the centre-right led by Mr Rasmussen its overall majority.
"Tonight we have been given an opportunity, but only an opportunity, to take leadership in Denmark," Mr Rasmussen told supporters in parliament.
"We take that upon ourselves and I take that upon myself ... What I offer today is to put myself at the head of a government," he said.
DF's strong results were expected, but the party has been coy throughout the campaign about whether it would join a government for the first time in its 20-year history.
It could leave the Liberals to form a government by themselves but support their policies in parliamentary votes, as it has done before.
"What we have said before the election is also what we will follow after the election - that we will be where the political influence is greatest," said DF leader Kristian Thulesen Dahl.
"If that is in a government, then that is where we will be. If it is outside of the government, then that is where we will be. That is the driver for us, not ministerial titles."
DF is acutely aware of the experience of other smaller parties in Denmark and elsewhere in Europe who, once in government, bled support due to compromises made with mainstream parties.
Staying on the sidelines may paradoxically secure it more influence.
The party has already managed to set the agenda on some issues without being in government.
Mainstream parties across the political aisle talked about curbing immigration, following the DF lead, and DF won an important concession from centre-right parties on its stance on the European Union.
Just before the election, the centre-right parties agreed to support British Prime Minister David Cameron's bid to reform the EU.
DF also wants to go further and call an in-or-out referendum on EU membership for Denmark.