Olaf Scholz set his sights on the German chancellorship on Monday after his centre-left party narrowly came out on top in the general election.
The Social Democrats (SPD) edged out Armin Laschet’s Christian Democrats (CDU), the party of departing Chancellor Angela Merkel, which scored its worst-ever result.
The narrow result paves the way for complex coalition talks, meaning Mrs Merkel could still be in office at Christmas.
Mr Scholz hopes to form a government with two smaller parties, the Greens and the Free Democrats (FDP).
However, Mr Laschet could still become chancellor if the two kingmakers choose to side with him instead.
The SDP won 25.7 per cent of the vote, becoming the largest party in parliament for the first time since 2002. The CDU and its sister party won 24.1 per cent.
The Greens won their highest ever vote share – 14.8 per cent – but their hopes of winning the chancellorship ended in disappointment.
The FDP, which is politically closer to the CDU but has not ruled out working with Mr Scholz, made small gains to win 11.5 per cent.
Scholz's traffic-light bid
Mr Scholz said the gains for the SPD, Greens and FDP were a mandate for the parties to form a government. This would be known as a "traffic light" coalition, named after the three parties' colours.
“The voters have spoken very clearly. They have said who should form the next government,” he said in Berlin on Monday.
“They strengthened three parties – the SPD, the Greens and the FDP. That is the visible mandate expressed by the voters. Those three should lead the next government.”
Mr Scholz's calm manner was credited with leading the SPD out of a years-long slump. The party trailed third in the polls as recently as July.
But the CDU has not given up on winning the chancellorship. Mr Laschet would have a majority if the FDP and Greens agreed to work with him instead.
“It’s now about who can form a stable government, a coalition of the future,” CDU general secretary Paul Ziemiak told German TV on Monday.
“There are these two options in parliament, and the question is who will get a majority. Armin Laschet is an experienced negotiator.”
Mr Laschet outmanoeuvred a more popular rival to secure the CDU's nomination, but struggled to motivate the party’s base and made a series of missteps.
He acknowledged the CDU's slump was a "loss of votes that isn't pretty". The bloc's previous worst showing was 31 per cent at the first postwar election in 1949.
But he said that, with Mrs Merkel departing after 16 years in power, “no one had an incumbent bonus in this election”.
Christian Lindner, the leader of the FDP, invited the Greens to discuss their positions before they approach the two larger parties.
Both have worked with the CDU and SPD in regional governments, but such a three-way coalition has never been done at national level.
Green leader Annalena Baerbock said that “the climate crisis … is the leading issue of the next government, and that is for us the basis for any talks … even if we aren’t totally satisfied with our result”.
An alternative that was much discussed during the election, a leftist alliance between the SPD, Greens and Die Linke – a far-left party – will not have a majority.
The sixth group in parliament, the far-right Alternative for Germany (AfD), is shunned by all other parties. It made slight losses and won 10.3 per cent.
Another possibility is a renewal of the current “grand coalition” between the CDU and SPD, although both parties would prefer to avoid this.
Mrs Merkel stays in office as a caretaker until the new parliament approves a successor. There are no formal limits on her powers, but previous chancellors have not made radical decisions in this period.
Turnout at the election was 76.6 per cent, slightly up on four years ago.
Whichever parties form the next German government, Mr Lindner said it was good news for Europe that it would have a majority with centrist parties.
“All of those in Europe and beyond who were worried about Germany’s stability can now see: Germany will be stable in any case,” he said.
For the first time since 1949 the SSW party, which represents Danish and Frisian minorities, was set to win a seat in parliament.
In two regional elections also held on Sunday, the SPD looked set to defend the post of Berlin mayor that they have held for two decades. The party was also on course for a strong win in the north-eastern state of Mecklenburg Western-Pomerania.