BERLIN  - German Chancellor Angela Merkel agreed on a coalition government with her main rivals the Social Democrats Wednesday, two months after her conservatives won elections but fell short of a ruling majority.

Merkel’s Christian Democratic Union (CDU), their Bavarian allies the CSU and the centre-left Social Democratic Party (SPD) held 17 hours of marathon talks before bleary-eyed party leaders delivered the deal before dawn. In the tense final round of talks that capped five weeks of political horse-trading, the SPD scored key concessions, including a national minimum wage from 2015, while Merkel stuck to her guns on her own red-line issues, blocking higher taxes for the rich and opposing new debt from next fiscal year.

The chancellor hopes to be sworn in for a third four-year term on December 17 as leader of Europe’s biggest economy, but a key hurdle remains: SPD members must still sign off on the proposed left-right “grand coalition” in a binding ballot next month.

“We negotiated hard till the end,” said SPD general secretary Andrea Nahles, emerging from the Berlin talks in the early hours, adding that “for us it’s a package that, I believe, we can present to our members”.

“The result is good for our country and carries a strong Christian-Democratic imprint,” said CDU general secretary Hermann Groehe, while his CSU counterpart Alexander Dobrindt voiced satisfaction that “all our key elements are reflected in the coalition contract”.Despite the late-night breakthrough, another political nail-biter looms in the coming weeks. The outcome of the SPD rank-and-file postal ballot, expected December 14, remains far from certain because many members reject the notion of their traditionally blue-collar party again governing in the shadow of powerful Merkel, as it last did in 2005-2009.

After that uneasy political marriage, the SPD suffered two humiliating electoral defeats in a row, winning less than 26 percent against the conservatives’ nearly 42 percent in the September 22 ballot.

SPD chief Sigmar Gabriel, who would be Merkel’s vice chancellor, hopes to convince the base of his 150-year-old party with the policy trophies his team has wrested from the conservatives.

The centre-left daily Sueddeutsche Zeitung said Social Democrats would be wise to back the pact.

“You can’t expect more from a grand coalition than small steps. But is it worth rejecting? Surely not,” it said.

To avoid the impression that SPD chieftains are worried only about gaining ministerial posts for themselves, they forced an agreement to stay silent for now on who would get which portfolio in the next Merkel cabinet.

Negotiators have only said that the CDU and SPD are set to get six ministerial posts each, and the CSU three.

In the protracted talks, the SPD scored a victory on its core demand, a minimum wage of 8.50 euros ($11.50) per hour from early 2015 to help the country’s army of working poor, despite the CDU/CSU’s fear that it will cost jobs.

The move aims to narrow a wealth gap brought about by decade-old labour reforms but should also cheer critics in the United States, the International Monetary Fund and Europe who want the European export power to stimulate domestic demand and correct its lopsided trade balance.

The SPD also pushed through a demand for a women’s quota on the boards of listed companies - which will be required to have at least 30 percent women members, to be phased in from 2016 - and the scrapping of a ban on dual nationality, a key demand of Germany’s large Turkish immigrant community.

Both sides also agreed on pension increases to protect retirees in rapidly ageing Germany, and to boost financing for education.

On Germany’s green energy transition, they compromised on a renewable energy target of 55-60 percent of total electricity demand by 2030.

Bavaria’s CSU also brought home the bacon on its own pet issue - charging foreign drivers a toll for using Germany’s famed autobahn highways, as long as this is in line with European Union rules.

Major sticking points that delayed the talks focused on financing. In the end, the additional spending and investment agreed by all sides until 2017 amounted to 23 billion euros.

Political scientist Gero Neugebauer of Berlin’s Free University said each side could go to their constituents claiming a victory of sorts.

“To put it bluntly, the CDU wanted power, the CSU wanted the road toll and the SPD wanted to avoid getting slapped down by their own members,” he said.

Merkel, Gabriel and CSU chief Horst Seehofer were due to present details of the more than 18-page coalition deal later Wednesday.