BERLIN (Reuters) - The three parties exploring a possible coalition in Germany face an early test of their willingness to compromise on Thursday when they try to hammer out a common stance on deeply divisive immigration and asylum policy.

Members of the anti-immigration party Alternative for Germany (AfD) vote during the first plenary session of German lower house of Parliament after a general election in Berlin, Germany, October 24, 2017. REUTERS/Fabrizio Bensch

German Chancellor Angela Merkel is trying to patch together a tricky three-way coalition after her party suffered bruising losses in a national election three weeks ago - losses that even some of her allies blame on her refugee policies.

Germany’s demographic landscape changed overnight in 2015 with her decision, in the face of refugee flows on a scale not seen since World War Two, to open the borders to over a million migrants fleeing war in the Middle East and Africa.

While some hailed the move as a humanitarian act, it was less popular in her own conservative camp, where many blame her for the subsequent surge in the anti-immigration Alternative for Germany party, which took seats from her bloc.

Within her conservative bloc, the Bavarian Christian Social Union (CSU) is demanding a cap on refugee numbers, rejected by Merkel as unconstitutional. To her left, the Greens oppose what they see as a populist-driven tightening of asylum rules.

With parties far apart, Christian Lindner, leader of the pro-business Free Democrats (FDP) warned that talks could rapidly descend into conflict with Greens on the sensitive matter of allowing family members to join migrants in Germany.

“The CSU’s talk of an upper limit is empty,” Lindner told Der Spiegel magazine. “But I have sympathy for the CSU’s calls for a change in immigration policy given the need for order,” he added, warning Merkel against compromising with the Greens.

“Once control has been re-established, then we can be more open again on family reunification,” he said. “Until then it must be strictly limited to cases of hardship and to the core family - parents and children.”

In the first two round of coalition talks, the three parties defied expectations by finding substantial common ground on fiscal policy.

But politicians from all parties have said it could take months to clinch agreement on what would be Germany’s first three-way coalition for decades.