Chancellor Angela Merkel and her rebellious political allies broke an impasse over immigration that threatened to bring down Germany's coalition government by agreeing on a compromise late Monday that both sides said addressed their concerns.
Ms. Merkel has been at odds for more than three weeks with Interior Minister Horst Seehofer over his insistence that migrants who have sought asylum elsewhere in the European Union should be turned away at Germany's borders. Mr. Seehofer leads the Christian Social Union, the sister party to the chancellor's Christian Democratic Union.
Ms. Merkel was equally steadfast in arguing that such a unilateral action would cause other countries to close their borders and jeopardize the passport-free movement that is a hallmark of Europe's Schengen zone.
But the two emerged from about five hours of talks saying they agreed to establish "transit centers" on Germany's border with Austria where asylum-seekers would be evaluated and, if it turned out they already had applied for protection in another EU country, sent back to that country.
Individuals who are rejected by those countries will be pointed back into Austria "upon agreement" with Vienna, according to the deal that Merkel called a "very good compromise."
"The spirit of partnership within the European Union is protected, and at the same time it's a decisive step to regulate and organize secondary migration," she told reporters without taking questions.
It was not immediately clear whether Austria had already agreed to the provision. Whether the two conservative parties would be able to get Merkel's junior coalition partner, the center-left Social Democratic Party, to agree also was an open question. The Social Democrats previously rejected the idea of transit centers.
While the deal sounded very similar to one offered by Merkel and rejected by Seehofer last week, the interior minister said he was happy with it, saying the compromise would have a "very clear lasting effect on the future."
Seehofer offered his resignation both as interior minister and leader of the Bavaria-only CSU at a party meeting Sunday. He agreed to put it off until after one more round of talks with Merkel and said Monday he would remain in both posts.
"I'm happy we were able to achieve this compromise, and it shows that it pays off to fight for your convictions," Seehofer said.
Seehofer and Merkel have long had a difficult relationship and sparred over Germany's approach to managing immigration on and off since 2015, when the chancellor welcomed refugees into the country.
However, the current dispute arose as far fewer newcomers have sought to enter Germany. It came ahead of a difficult Bavarian state election set for October that has the CSU determined to show that it is tough on migration.
In recent days, speculation focused on the possibility that Merkel would fire Seehofer if he went ahead with his plan. That would likely have ended the seven-decade partnership of the CDU and CSU, which have a joint parliamentary group, and would leave the government just short of a majority.
In comments to the Sueddeutsche Zeitung newspaper ahead of Monday's renewed talks with Merkel, Seehofer complained he was in an "inconceivable" situation.
"I won't let myself be fired by a chancellor who is only chancellor because of me," he was quoted as saying, an apparent reference to the CSU's traditionally strong election results in Bavaria.
Before the sides met, CDU leaders and lawmakers stressed the importance of maintaining the conservative alliance, Germany's strongest political force for much of its post-war history.
Merkel had argued a plan to regulate immigration that EU leaders approved Friday and bilateral agreements in principle that she hashed out with some EU countries for them to take back migrants would accomplish what Seehofer seeks.
But the more conservative CSU worried its credibility was at stake as it tries to curb support for the rival anti-migration Alternative for Germany party, known as the AfD, in the Bavarian election.
So far, however, the gambit has played poorly in polls and Germans seem to be losing their patience.
"I think it's caused by the atmosphere with the AfD," said Joerg Hauvede, as he left Berlin's main train station. "I hope that the CSU will receive their just deserts for their actions."
The Social Democrats, who have largely been bystanders so far, demanded that their coalition partners get their act together, and planned a meeting with the conservative leaders. Party leader Andrea Nahles said "the CSU is on a dangerous ego trip that is paralyzing Germany and Europe."
"The blame game between CDU and CSU must end, because it is irresponsible," she said.
This story was reported by The Associated Press.