German Chancellor Angela Merkel's conservatives and the Social Democrats sealed a deal Wednesday on a new coalition, officials said, potentially ending four months of political deadlock in Europe's top economy.
The parties ironed out their final differences and were ready to sign an agreement for Merkel's fourth term, her chief of staff and acting finance minister Peter Altmaier said, calling it a "good day for our country".
"We have a coalition agreement that will do a lot of positive things for a lot of citizens," Altmaier told reporters after he emerged from more than 24 hours of contentious talks.
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 Christian Democratic Union and its Bavarian sister party Christian Social Union (CDU/CSU) and the Social Democratic Party must still be approved by the SPD's skeptical rank-and-file.
"I think this is an excellent result, in terms of content as well as with regards to the ministries, senior Social Democrat lawmaker Hubertus Heil said. "We can be very satisfied."
Alexander Dobrindt, the CSU's top federal lawmaker, said it had been time for negotiators to come out of their "trenches" and "we succeeded."
"It was time to have the prospect of a government in Germany," Dobrindt told reporters. "So it's a good morning."
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.
Merkel, in power for over 12 years, at first tried to cobble together a novel three-way coalition with the Greens and the liberal Free Democrats, but those efforts collapsed in November.
Faced with snap elections that could further boost the AfD or the prospect of heading an unstable minority government, she opted to woo back the SPD -- her junior partner for two of her three terms since 2005.
SPD leader Martin Schulz then abandoned 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 major concessions 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 remits.
Media reports said Schulz, a former European Parliament chief, was now set to take over the foreign ministry and would give up the party chairmanship in return.
Meanwhile the finance job could go to the popular mayor of northern port city Hamburg, pro-business centrist Olaf Scholz, who has often been 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 have agreed on sticking 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 heading a minority government -- a prospect she has baulked at.
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 leveling 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.
A recent Insa poll found that support for the CDU/CSU had fallen from 33 to 30.5 percent, while the SPD slipped from September's historic low of 20.5 percent to 17 percent.
The AfD meanwhile scored a record 15 percent.