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.
"After a tough struggle and some hard days, we've found a really good compromise", said Merkel, who heads the Christian Democratic Union (CDU).
However, criticism from Vienna and her junior coalition partners, the Social Democrats (SPD), threatened to throw a spanner in the works.
It was also about whether there was in fact a wider European "we" that could be borderless when it came to movement, multilateral when it came to solutions and liberal when it came to ideals such as the right to seek asylum, equality under the law and individualised treatment.
Under the German deal, migrants who have already applied for asylum in other European Union countries will be held in transit centers on the German border with Austria while Berlin negotiates bilateral accords for their return.
Austria's government has warned it could "take measures to protect" its borders after Germany planned restrictions on the entry of migrants as part of a deal to avert a political crisis in Berlin.
In high-stakes crisis talks on Monday, Ms. Merkel put to rest for now a risky row with a longtime rival, Interior Minister Horst Seehofer, that had threatened the survival of her shaky 100-day-old coalition.
The compromise deal between Merkel and Seehofer suggests refugees arriving at the Austrian-Bavarian border who were first registered in European Union states that now refuse to take them back, such as Hungary, should be sent back to Austria.
Jens Spahn, an arch critic of Merkel's migrant policy, may be unpalatable to many in the CDU, especially after making some controversial comments on poverty and being photographed with the new, outspoken US ambassador, a defender of US President Donald Trump.
He could defy her orders by ordering border police to carry out his plan, which would force her to fire him and nearly certainly break up the CDU-CSU alliance, or he could accept a humiliating climbdown or resign.
Merkel, however, rejected a key provision: turning back at the border all migrants previously registered in another European Union country as a unilateral act that would come at the expense of other member states.
As he entered a CDU crisis meeting Monday, party deputy leader Armin Laschet insisted that the sister parties "want to hold onto" their alliance.
The chancellor's frantic last-minute diplomacy was ultimately prompted by the CSU's fear of losing its cherished absolute majority in Bavaria's state parliament.
However, the more conservative CSU believes its credibility is at stake as it tries to curb support for the rival anti-migration Alternative for Germany party in the Bavarian election.
Merkel has survived a populist wave that has swept through Europe longer than most German leaders, but the wave has now left her grip on the country vulnerable. Seehofer seemed certain to walk away from the government after Merkel failed to compromise on her strong open-borders convictions, however, an agreement to tighten borders has reportedly been struck.
"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.
Merkel could have fired Seehofer.