Germany's Social Democrats (SPD) narrowly won Sunday's national election, projected results showed, and claimed a "clear mandate" to lead a government for the first time since 2005, ending 16 years of conservative-led rule under Angela Merkel.
The centre-left SPD was on track for 26 per cent of the vote, ahead of 24.5 per cent for Mrs Merkel's CDU/CSU conservative bloc, projections for broadcaster ZDF showed.
But both groups believed they could lead the next government.
With neither bloc holding a majority and both reluctant to repeat their awkward "grand coalition" of the past four years, the most likely outcome is a three-way alliance led by either the SDP or Mrs Merkel's conservatives.
Agreeing on a new coalition could take months, and will probably involve the smaller Greens and liberal Free Democrats (FDP).
"We are ahead in all the surveys now," the SPD's selection for chancellor, Olaf Scholz, told other candidates after the vote.
"It is an encouraging message and a clear mandate to make sure that we get a good, pragmatic government for Germany."
The SPD's rise marks a swing to the left for Germany and a remarkable comeback for the party, which has recovered about 10 points in support in just three months to improve on its 20.5 per cent result in the 2017 national election.
Mr Scholz, 63, would become the fourth post-war SPD chancellor after Willy Brandt, Helmut Schmidt and Gerhard Schroeder. He is the Finance Minister in Mrs Merkel's Cabinet and a former mayor of Hamburg.
Mr Scholz's conservative rival, Armin Laschet, indicated that his bloc was not yet ready to concede, although his supporters were subdued.
"It hasn't always been the first-placed party that provided the chancellor," Mr Laschet, 60, told the other candidates.
"I want a government where every partner is involved, where everyone is visible – not one where only the chancellor gets to shine," he said in an early attempt to impress smaller parties.
Schmidt ruled in the late 1970s and early 1980s in coalition with the FDP, even though his SPD had fewer parliamentary seats than the conservative bloc.
Attention will now shift to informal discussions followed by more formal coalition negotiations, which could take months, leaving Mrs Merkel in a caretaker role.
Mr Scholz and Mr Laschet said they would aim to strike a coalition deal before Christmas.
Mrs Merkel plans to step down after the election, making the vote an era-changing event to set the future course of Europe's largest economy.
She has stood large on the European stage almost since taking office in 2005, when George W Bush was US president, Jacques Chirac was in the Elysee Palace in Paris and Tony Blair was British prime minister.
After a domestic-focused election campaign, Berlin's allies in Europe and beyond may have to wait months before they can see whether the new German government is ready to engage on foreign issues to the extent they would like.
A row between Washington and Paris over a deal for Australia to buy US instead of French submarines has put Germany in an awkward spot between allies, but also gives it the chance to help heal relations and rethink a common stance on China.
On hearing that the SPD were slightly ahead in polls, US President Joe Biden said in Washington: "I'll be darned. They're solid."
French President Emmanuel Macron is eager to forge a common European fiscal policy, which the Greens support but the CDU/CSU and FDP reject. The Greens also want "a massive expansion offensive for renewables".
"Germany will end up with a rather weak chancellor who will struggle to get behind any kind of ambitious fiscal reform at the EU level," said Naz Masraff at political risk consultancy Eurasia.
Whatever coalition ends up in power, Germany's friends can at least take heart that moderate centrism has prevailed, and the populism that has taken hold in other European countries failed to break through.
The projected results for ZDF showed the far-right Alternative for Germany on track for 10.5 per cent, worse than four years ago when they stormed into the national parliament with 12.6 per cent of the vote.
All mainstream blocs have ruled out a coalition with the party.