Horst Seehofer agrees to a border control deal with Angela Merkel

Angela Merkel made a deal on migration with her rebellious interior Minister Horst Seehofer, defusing the bitter scandal that threatened her government.

Both sides hammered out “a good compromise … after a difficult struggle”, Merkel said on Monday evening, adding that it involved setting up holding and processing centres for asylum seekers near German borders.

“We have reached an agreement after very intense negotiations,” Seehofer agreed, stressing that he intended to stay on in his cabinet post after earlier threatening to quit.

“We now have a clear agreement how to prevent illegal immigration across the Austrian-German border in future,” said Seehofer, whose Christian Social Union (CSU) party is the traditional Bavaria state ally of Merkel’s Christian Democratic Union (CDU) party.

He added that details would be released soon.

The agreement still requires the consent of Merkel’s other coalition partner, the centre-left Social Democrats, to become government policy.

Nonetheless, it suggested that Merkel – in power for over 12 years, and the EU’s longest serving leader – goes on to live another day after surviving the latest bruising challenge to her authority.

Merkel has faced a strong backlash, and been weakened at the polls, over her 2015 decision to keep open German borders to a mass influx of migrants, many from war-torn Syria, that led to more than one million arrivals.

Public anger and fear about the newcomers have given rise to the far-right Alternative for Germany (AfD) party, which entered parliament last year and threatens Seehofer’s CSU in Bavarian state polls in October.

Seehofer, a long-time Merkel critic, had openly challenged her with a plan to unilaterally shutter German border crossings with Austria to many asylum seekers, effectively daring the chancellor to fire him.

The threat – and Seehofer’s subsequent warning he may resign – had raised the spectre of a break in the seven-decade-long partnership between their conservative CDU and CSU parties.

This would have deprived Merkel of her narrow parliamentary majority and forced her to either seek a new coalition partner or call a second election within a year, after scoring poor results in last September’s vote.

That scenario scared all parties except the anti-immigration AfD which, polls suggest, could hope for further gains.

As Merkel stuck to her guns during the crisis, and won key concessions from EU partners on toughening migration rules, Seehofer and the CSU faced increasing pressure from all other parties.

The CSU softened its stance this week in the face of withering criticism across party lines and the media, and poor polling results, with other leaders stressing that the alliances must live on.

The situation was further complicated after the third partner in Merkel’s government, the Social Democrats, made clear that it would not blindly sign off on what the CDU/CSU may agreee on.

The flashpoint issue was Seehofer’s demand to order German border police to turn back asylum seekers already registered elsewhere in the EU, and his threat to do so against Merkel’s wishes.

Merkel rejects such unilateral German measures and last week reached an EU-level agreement instead that toughens immigration rules, as well as several bilateral deals allowing Germany to turn back many migrants.

In Monday’s deal, both sides agreed to set up closed “transit centres” – similar to existing facilities at airports – that would allow German authorities to speedily process applicants and, if they are rejected, repatriate them to their EU arrival country if that state agrees.