preliminary official results reported early Monday.
The federal German election agency posted the results at 4:30 a.m. local time.
The close outcome means the Social Democrats, with only 25.7 percent of the vote, must team up with other parties to form a government. And in the complex equation that can be required in Germany to form a government, it is possible that if the winning party fails to get others on board, the party that placed second could wind up leading the country.
It could take weeks if not months of haggling to form a coalition, leaving Europe’s biggest democracy suspended in a kind of limbo at a critical moment when the continent is still struggling to recover from the pandemic and France — Germany’s partner at the core of Europe — faces divisive elections of its own next spring.
Sunday’s election signaled the end of an era for Germany and for Europe. For over a decade, Ms. Merkel was not just chancellor of Germany but effectively the leader of Europe. She steered her country and the continent through successive crises and in the process helped Germany become Europe’s leading power for the first time since World War II.
Cheers erupted at the Social Democratic Party’s headquarters when the exit polls were announced early Sunday evening. A short while later, supporters clapped and chanted “Olaf! Olaf!” as Olaf Scholz, their candidate, took the stage to address the crowd.
“People checked the box for the S.P.D. because they want there to be a change of government in this country and because they want the next chancellor to be called Olaf Scholz,” he said.
The campaign proved to be the most volatile in decades. Armin Laschet, the candidate of Ms. Merkel’s Christian Democrats, was long seen as the front-runner until a series of blunders compounded by his own unpopularity eroded his party’s lead. Olaf Scholz, the Social Democratic candidate, was counted out altogether before his steady persona led his party to a spectacular 10-point comeback. And the Greens, who briefly led the polls early on, fell short of expectations but recorded their best result ever.
The Christian Democrats’ share of the vote collapsed with only 24.1 percent of the vote, heading toward the worst showing in their history. For the first time, three parties will be needed to form a coalition — and both main parties are planning to hold competing talks to do so.
Nevertheless, Mr. Laschet appeared at his party headquarters an hour after the polls closed, declaring the outcome “unclear” and vowing to try to form a government even if his party came in second.
The progressive, environmentalist Greens appeared to make significant gains since the 2017 election but seemed to fall short of having a viable shot at the chancellery. That positions the Greens, as well as the business-friendly Free Democrats, to join the next government. They will play a key role in deciding what the next German government could look like, depending on which of the larger parties they would like to govern with.
On the outer edge of the political spectrum, support for the far-right Alternative for Germany, or AfD, appeared roughly unchanged, while the Left party appeared to be hovering on the 5 percent threshold needed to win seats in Parliament.
In mid-October the election agency will present the official final results.