WEGSCHEID, Germany (Reuters) - Two years ago, Wegscheid was on the front lines of Europe’s refugee crisis. When Germany voted last week, the village, like many along the Austrian border, swung hard to the far right, straining Chancellor Angela Merkel’s conservative alliance.

FILE PHOTO: Migrants are escorted by German police to a registration centre, after crossing the Austrian-German border in Wegscheid near Passau, Germany, October 20, 2015. REUTERS/Michael Dalder/File Photo

After bruising election losses, Merkel is trying to patch together a tricky three-way coalition of her conservatives and their Bavarian allies, the pro-business Free Democrats (FDP), and the environmentalist Greens.

Her task is complicated by the Bavarian conservatives, who worry about losing their regional dominance in a state election next year. To win support, they are demanding a controversial cap on the number of migrants entering Germany.

Merkel dismisses the cap as unconstitutional. The Greens reject it too. On Sunday, the chancellor’s Christian Democrats (CDU) and the Bavarian Christian Social Union (CSU) - sister parties - will meet to try to resolve their differences.

Both suffered heavy losses in the Sept. 24 federal election to the anti-immigration Alternative for Germany (AfD) party, which won seats in the national parliament for the first time.

All along Germany’s southern border, where in 2015 thousands of refugees fleeing war in the Middle East poured into Germany, voters deserted the CSU for the AfD.

In Passau, the electoral district where Wegscheid lies, the CSU’s vote fell 13.4 points from four years ago to 40.5 percent - a low figure in Bavaria, often jokingly called a one-party state. The AfD’s share shot up 12.1 points.

“The politicians are to blame for the AfD being elected,” said pensioner Reinhold Turtschan in the baroque market square of nearby Deggendorf, where the AfD’s vote soared by 15.2 points, mirroring the CSU’s 15.6 point fall.

“The asylum seekers, I don’t want to criticize them, but they get so much money while we pensioners have to be so careful with our finances just to get through the month,” he said.

The setback in a wealthy, conservative state where the CSU has reigned without a break since the late 1950s has prompted recriminations within the party, with some blaming Merkel’s 2015 decision to open the borders to a million migrants.

For decades, the CSU has been a national player thanks to its unassailable strength in Bavaria, allowing it to contribute up to a fifth of the joint conservative bloc’s lawmakers.

The mountainous south-eastern state with its distinctive dialect, lederhosen leather shorts and traditional dirndl dresses rose from Germany’s poorest, most agricultural state after World War Two to one of its richest regions today.

THE UPPER LIMIT

Now the CSU is in a bind over how best to recover. Those who blame the refugee crisis for the AfD’s success demand an immigration ceiling of 200,000 refugees a year. The CDU rejects the idea.

Highlighting their tensions, the Sueddeutsche Zeitung newspaper this week reported CSU leader Horst Seehofer as saying his party and Merkel’s CDU faced their biggest challenge since 1976 - when his predecessor Franz-Josef Strauss threatened to break up their alliance.

On Sunday, two sister parties will sit down to agree a common program ahead of coalition talks with the other two parties. Alexander Dobrindt, the CSU’s chief in the national parliament, described the cap as “non-negotiable”.

But by holding firm to avoid being outflanked by the AfD, the CSU risks alienating the Greens, who reject an upper limit.

In Wegscheid, where in the summer of 2015 residents grew used to being awakened by migrants rapping on windows asking for directions in the dead of night, the mayor, Lothar Venus, doubts the answer is so simple.

“The AfD only has one theme, refugees. But Germany’s issues go far further,” he said, standing by the border crossing where people smugglers would drop refugees off, leaving them to walk across the bridge into Germany.

He blamed Seehofer, who faces calls for his own resignation, for pushing for a cap he cannot deliver rather than focusing on infrastructure failings, such as poor mobile coverage and slow Internet, that residents complain about.

Michael Mayer, a historian at the Academy for Political Education near Munich, said moving right was risky for the CSU.

“It’s the mistake people have always made in Europe: running after the far right first strengthens them and then you lose votes yourself,” he said.