Germany's centre-left Social Democrats took a narrow lead on Chancellor Angela Merkel's conservatives in Sunday's vote to decide her successor, partial results showed, sparking immediate claims from both sides to form the country's next government.
The epochal election ushers in the end of 16 years in power for Merkel, and also thrusts Germany, a byword for stability, into a new period of political uncertainty.
With the conservative CDU-CSU alliance and the SPD each seeking to form governing coalitions in a race for power, Germany was up for a rocky few months that could blunt it on the international stage for some time.
Partial results published on public television showed Finance Minister Olaf Scholz's SPD with around 25.9 to 26.0 percent of the vote, followed closely behind by Merkel's Christian Democrats and their candidate Armin Laschet on about 24.1-24.5 percent.
The SPD swiftly staked its claim with general secretary Lars Klingbeil saying his party "clearly has the mandate to govern".
"It's going to be a long election night, that's for sure," Scholz said.
But he said it was "certain" that many Germans "want there to be a change in government and also... want the next chancellor to be called Olaf Scholz".
With the conservatives staring down the barrel of their worst result since World War II, CDU general secretary Paul Ziemiak admitted that the "losses are bitter compared to the last election" in 2017, when the CDU-CSU under Merkel notched up 33 percent.
But Laschet, 60, warned that the jury was still out on which party will end up leading the country, as he vowed to "do everything we can to build a government led by the (conservative) Union".
Scholz and Laschet both said they would aim to cobble together a ruling majority by Christmas.
With all still to play for, the mood at both parties' headquarters was tense.
"I am disappointed that the SPD is more or less level with the CDU-CSU. But it remains exciting what coalition possibilities will now emerge," said Oliver Pawloski, 39, a member of the SPD.
At the CDU, Alfons Thesing, 84, put the finger on the problem for his party. "It hurts a lot that Merkel is no longer there," he said.
Illustrating the poor showing for the CDU, Merkel's own Baltic coast constituency -- which she had held since 1990 -- was taken by the Social Democrats.
- Blunders -
The SPD, Germany's oldest party, was polling so badly just a few months back that many had written off the possibility that it may even be in the next government.
But Scholz, 63, a colourless but competent former mayor of Hamburg, now stands a chance of becoming the first SPD chancellor since Gerhard Schroeder, who lost to Merkel in a close contest in 2005.
It was a dramatic reversal of fortunes, considering that the conservatives' candidate Laschet went into the race as the clear favourite to grab the top job in Europe's biggest economy.
Laschet's popularity began to wane after a series of blunders over the summer, including being caught on camera laughing in the background during a tribute to the victims of devastating floods.
In the meantime, Scholz saw his ratings begin to rise as he capitalised on his proximity to Merkel as finance minister in her cabinet, and avoided making such embarrassing mistakes.
Alarmed by polls predicting a devastating defeat for Laschet, the conservatives trotted out their biggest asset -- Merkel.
Although she had originally planned to keep a low profile in the campaign, she found herself dragged into Laschet's frantic cross-country tour -- helping the party to stem a drop in popularity in the last days before the vote.
- Green role -
Although climate change had been one of the top concerns among voters in the run-up to the vote, it did not translate into a sweep for the ecologist Greens.
For political analyst Karl-Rudolf Korte, Sunday's outcome showed that there is "no clear climate for change -- rather it's a yearning for a new beginning but coupled with stability, more of the same".
The Green party enjoyed a surge in support earlier this year after naming 40-year-old Annalena Baerbock as its chancellor candidate, at one point even briefly taking the lead as the most popular party.
But after a series of missteps by Baerbock, including a plagiarism scandal, the Greens fell well behind the two leading parties, the early results showing them just under 15 percent of the vote.
While the chancellery may be out of reach for the Greens, the party will likely have a junior role in Germany's next government.
Both Scholz and Laschet will be seeking to woo the Greens. Likewise, they will be trying to get the liberal FDP on their side to make up the numbers.
As the FDP is a natural bedfellow with the conservatives rather than the centre-left, and the Greens in turn favour the SPD, a real game of poker could emerge in the next weeks.
Horse-trading had already begun with the count still on.
In a televised talk show with party chiefs, FDP leader Christian Lindner said it might be "advisable" for his party and the Greens "to first talk to each other" before deciding whether to partner with the conservatives or the SPD.