Germany's ruling coalition has agreed on a faster procedure for screening migrants at the border, dropping the idea of creating new holding centres.
The deal concerns irregular migrants already registered in another EU country, who are to be sent back.
Earlier Chancellor Angela Merkel's coalition was at risk of collapse as her interior minister, Horst Seehofer, wanted police to keep migrants out.
Migrants are to be screened within 48 hours at existing transit facilities.
Mr Seehofer told reporters he was "extremely satisfied" with the deal, despite having to drop his demand for new transit centres.
For weeks his dispute with Mrs Merkel threatened to break up the decades-old alliance between his conservative Bavarian CSU party and her Christian Democrats (CDU).
The deal requires irregular migrants to be processed at police facilities on the border if they cannot be transferred to Munich airport, and processed within 48 hours. They will remain in transit throughout, so legally not entering Germany.
A migrant proven to have registered in another EU country will be sent back, provided Germany has a corresponding agreement with that country.
Mrs Merkel says Greece and Spain are willing to take migrants back. However, Italy - the main arrival point for most migrants from North Africa - does not yet have a bilateral deal with Germany.
Currently the numbers of such migrants arriving at Bavaria's border with Austria are 10 or fewer daily, the German government says. Many more arrived daily in 2015-2016, when Mrs Merkel controversially allowed in more than a million asylum seekers.
Political tensions remain
BBC's Berlin correspondent Jenny Hill
Each party is claiming a principled victory. This was always a political row and had little to do with a practical problem at the German border.
The Social Democrats (SPD) - for whom the horror of an illiberal migration policy is eclipsed only by a terror of coalition collapse and new elections - agreed quickly (reportedly after just 30 minutes of talks) to a watered-down version of a plan agreed by Mrs Merkel and Mr Seehofer.
In return, the SPD got agreement that a new immigration law will be adopted later this year.
The bilateral agreements with other EU countries aren't exactly flooding in. Few expect the fragile peace to hold. Mr Seehofer - whose party still faces pressure from the anti-immigration Alternative for Germany (AfD) in a regional election this October - has already threatened to start agitating again if the measures aren't implemented.
Read more on this topic:
Italy's populist government has demanded more help from EU partners to house and process asylum seekers.
The EU is divided over the Dublin Regulation, under which the country where a migrant first arrives usually has to process his or her asylum claim.
Austria's right-wing Chancellor Sebastian Kurz, who is closer to Mr Seehofer than to Mrs Merkel on the migrant question, said "we have full confidence in Seehofer's words yesterday".
"He said no refugees will be sent back from Germany to Austria," Mr Kurz said, when asked about the German coalition deal.