Merkel has seen her standing at home and abroad weakened by the longest stretch of coalition-building in the country's postwar history
German Chancellor Angela Merkel's conservatives and the Social Democrats sealed a deal on a new coalition Wednesday, potentially ending four months of political deadlock in Europe's top economy.
After a third extra day of negotiations that dragged on until dawn, a relieved Merkel told reporters the agreement would create "the good and stable government that our country needs and that many in the world expect from us".
After making major concessions to get the accord, she acknowledged it had been a "long road that led us here" but added that "in the end, I think it was worth it".
Social Democrat leader Martin Schulz must submit the coalition agreement to his party's rank and file
The breakthrough will come as a relief to Germany's EU partners as the bloc faces tough negotiations on migration and Brexit.
Merkel, Europe's most experienced leader, has seen her standing at home and abroad weakened by the longest stretch of coalition-building in the country's postwar history.
But before she can be sworn in, a final hurdle looms: the hard-fought "grand coalition" pact between her CDU/CSU bloc and the Social Democratic Party must still be approved by the SPD's sceptical rank-and-file.
- SPD holds the keys -
Germany has been stuck in political limbo since September's inconclusive general election saw mainstream parties bleed support to the far-right AfD, which tapped into anger over Merkel's liberal refugee policy.
After a failed attempt to forge an untried alliance with two smaller parties, Merkel opted to woo back the reluctant SPD -- her junior partner for two of her three terms since 2005.
SPD leader Martin Schulz responded by abandoning his post-election vow to renew the party in opposition -- a U-turn that angered many.
But a copy of the coalition agreement obtained by AFP indicated that he was able to extract a high price from the conservatives in the final round of talks including control of the powerful finance and foreign ministries, as well as the labour, family affairs, justice and environment portfolios.
Julian Reichelt, editor-in-chief of the influential Bild daily, called it "the first SPD government led by a CDU chancellor".
Merkel admitted the debate on the division of ministries "wasn't easy" while Schulz held up the coalition deal as bearing "the strong signature of the Social Democrats".
Sources close to the talks said Schulz, a former European Parliament chief, was now set to take over the foreign ministry and would reportedly give up the party chairmanship in return. He declined to comment, saying any announcements would have to wait until after an SPD leadership meeting.
Meanwhile the finance job could go to the popular mayor of northern port city Hamburg, pro-business centrist Olaf Scholz, often eyed as a potential SPD chancellor candidate.
The change could mean a mild shift away from the austerity imposed at home and abroad by former finance minister Wolfgang Schaeuble, although the parties agreed to stick to a balanced budget policy.
Merkel's fate now lies in the hands of the SPD, as Schulz has promised to give his party's 460,000 members the final say on whether to accept the coalition pact.
Observers expect the referendum to be tight, with the SPD's left and youth wings fiercely opposed to another four years governing in Merkel's shadow.
The yes-or-no referendum will be held by postal ballot, with the result expected to be announced around March 4.
A green light could see a new Merkel-led government in place by the end of next month.
A thumbs-down could see the country headed for fresh elections or leave Merkel at the helm of an unstable minority government -- a prospect she has baulked at.
- Deeper European integration -
Schulz put a fairer Europe at the heart of his negotiating efforts, insisting that Berlin must join French President Emmanuel Macron's push to deepen eurozone integration.
According to the coalition deal, the parties agreed to support Macron's reform drive and tentatively backed his idea of a eurozone investment budget.
On the hot-button topic of migration, the two camps said they would aim to limit the annual intake to 180,000-220,000 people, a key CSU demand. CSU leader Horst Seehofer is also set to take control of a revamped homeland security ministry.
The SPD however won assurances that family reunifications for refugees would resume in August, restricted to 1,000 people a month.
An SPD push to overhaul the two-tier healthcare system also yielded results, with a new commission set to examine levelling out doctor pay under statutory and private insurance schemes.
But the protracted haggling has left its scars, and surveys suggest the two camps could lose their majority if a "no" vote from SPD members sends the country back to polling booth.