Bavarian conservative leader Horst Seehofer had threatened to resign his position as leader of his party and German Interior Minister if Dr Merkel failed to strike a bargain to control immigration to Germany - either multilaterally within Europe, or unilaterally at home.
Merkel and Seehofer, who heads Bavaria's ruling Christian Social Union (CSU), pulled back from the brink as they risked a coalition split that could have unraveled Merkel's chancellorship after nearly 13 years. Merkel rejected that proposal as a unilateral move that violated European asylum law and risked causing havoc with other EU governments.
German Minister of the Interior Horst Seehofer insisted on his plan to turn away asylum seekers at the border with Austria registered in other European countries, as he rejected EU deals reached last week by Merkel as inadequate.
"I am glad that this agreement has been reached". But if he had pulled the CSU out of the coalition, the government would have collapsed-and Merkel's career likely would have been over.
After half a year of coalition building, Seehofer, having been ousted by ambitious rival Markus Soeder as Bavarian state premier, returned to Berlin, where he previously held ministerial posts, to rejoin Merkel's cabinet.
"As such the spirit of partnership in the European Union is preserved and at the same time an important step to order and control secondary migration and that's why I think that we have found a good compromise after tough negotiations and hard days".
Bavaria's Interior Minister Joachim Herrmann, who has been tipped as a potential successor to Mr. Seehofer, said in a radio interview his party wanted an agreement with the CDU but gave no indication about what a compromise could look like. "With this the very spirit of partnership in the European Union is protected and at the same time, it is a decisive step towards organizing and managing secondary migration", Merkel said.
"In the end, the government could fall and an old, proud party could descend into ridiculousness - and all of that to solve a problem that in reality hardly is one", given the dramatically lower numbers of asylum seekers arriving in Germany this year. "And as a result we will see a crash - damaging both parties." .
She could also call a vote of no confidence.
"She was able to to compromise, but she's totally sold out her political principles with this".
Otherwise, a new election is possible.
While she still has CDU backing, Merkel is safe.
Merkel, who has been in office since 2005, warned last week the issue of migration could decide the very future of the European Union itself.
That decision convulsed European politics, fueling the rise of anti-immigration parties including the far-right Alternative for Germany (AfD) party, which now threatens to unseat the CSU in October's regional elections.