BERLIN — Germany’s conservative parties said Monday they have agreed on a law limiting the number of migrants allowed to enter the country every year — though the government and parliament will have the power to change the figure in the future.

Chancellor Angela Merkel’s party and its sister party in Bavaria, the Christian Social Union, say they want to limit the annual number of migrants to 200,000. However, that number can be increased or lowered by both the government and parliament in reaction to any future refugee crises.

The migrant issue had been one of the biggest stumbling blocks between the two parties as they head into coalition talks next week with the pro-business FDP and the Greens to form a new government following last month’s national election.

“I’m happy that we found a compromise,” Merkel told reporters in Berlin after negotiations that lasted deep into the night. “It’s important, that the basic right to asylum, that every application will be processed, will be maintained.”

The face-saving compromise was much needed after Merkel and the CSU’s leader, Horst Seehofer, wrangled over a migrant cap for almost two years. Merkel has repeatedly refused to agree to an annual cap for migrants, while the CSU had demanded a limit.

“We finally have a conclusive system of rules for migration,” Seehofer said.

While the CSU can now present an actual number to its party base, Merkel can point to the fact that the number is flexible and can be changed any time in reaction to incoming asylum seekers.

Germany took in more than 1 million migrants between 2015 and 2016, but the numbers have drastically gone down since the Balkans route was blocked in early 2016. Between January and August of this year, fewer than 124,000 people applied for asylum in Germany. A deal with Turkey has also kept large numbers of people from crossing the Mediterranean to Europe’s shores.

The compromise also includes plans to build large centers where asylum-seekers must stay until their requests have been processed. Asylum-seekers are currently distributed around the country while awaiting the decision on their applications.

It also seeks to add new immigration laws allowing for special migration of skilled workers and speed up the return of rejected asylum-seekers. Other plans include adding Morocco, Algeria and Tunisia to the list of so-called safe countries, which would make it near impossible for citizens from those countries to get asylum in Germany.

The migrant issue is likely to also play a big role in upcoming coalition negotiations as the Greens have been vehemently opposed to eroding asylum rights.

Compared with many other European countries, Germany has generous asylum laws. They are enshrined in the German constitution in reaction to the Third Reich, when many people fleeing the Nazis survived only because they were able to get asylum in other countries.