Here are the main points in the 177-page coalition treaty, which would become policy goals for the next government.
SPD leader Martin Schulz pushed through a demand that the repeat alliance be put to "a mid-term re-evaluation" after two years.
Schulz is hoping that the half-time assessment, which was not part of the previous two coalition pacts between the parties, will help sell the deal to the 460,000 SPD members who will have the final say on the agreement in an upcoming referendum.
A "no" vote would leave Merkel facing fresh polls, or the unappealing prospect of heading an unstable minority government.
The coalition treaty puts Europe front and centre, with the parties agreeing to support the ambitious EU reform drive of French President Emmanuel Macron to give the bloc "a new start".
As well as agreeing to strengthen EU foreign and defence policy, the parties say they are ready to raise Germany's contributions to the European Union's budget.
They also vow to "in close partnership with France, sustainably strengthen and reform the eurozone so that the euro can better withstand global crises".
They support the creation of a European Monetary Fund that could lend to countries in crisis, but offer only cautious backing for Macron's idea of a eurozone investment budget -- which Berlin fears could translate into a transfer of German cash to troubled economies.
The document makes no mention of Macron's controversial proposal for a common finance minister for the single currency area.
Thanks to flush public coffers, Germany plans to boost public investment while maintaining a balanced budget and refraining from tax hikes.
With some 45 billion euros ($56 billion) to play with, both camps agreed to reform the pension system threatened by a rapidly greying population, vowed to boost digitisation and improve education by pouring more federal funds into regional school systems.
The SPD secured some social welfare concessions, including on childcare and on making Germany's public-private healthcare system fairer.
The parties also committed to phasing out the so-called "solidarity surcharge" payments to Germany's lagging eastern states, introduced after reunification in 1990.
On energy and climate, they agreed to formally stick with Germany's carbon emission reduction goals, even if experts agree Germany looks set to overshoot its 2020 target.
The parties agreed to limit the numbers of refugees and migrants coming to Germany following the arrival of more than one million asylum seekers since 2015.
The mass influx drove the rise of the far-right Alternative for Germany (AfD) party which scored almost 13 percent in September elections.
According to the coalition pact, Germany will aim to limit the annual intake of people seeking safe haven to around 200,000, in line with a long-standing demand of the CSU.
Germany will also allow some refugees with temporary status to bring their families from August, but restrict the number of relatives coming at 1,000 a month.
Germany will consider additional "hardship cases", a term yet to be fully defined.
The parties reaffirm their commitment to NATO and support closer cooperation between the military alliance and the bloc.
But they make no mention of raising Germany's defence spending to meet NATO goals, as pushed for by US President Donald Trump.
Instead, they vow only to make "an appropriate contribution" to preserve NATO's defence and deterrence capabilities.
This appears to be a concession to the SPD, which vehemently objects to the NATO target of spending at least two percent of national output on defence.