MUNICH — All seems well in Bavaria.
The streets are clean, unemployment is practically nonexistent, social benefits are generous and a vibrant sense of identity infuses small villages and big cities alike: Even teenagers sometimes don dirndls and lederhosen for a night out at the disco.
Yet this is the new angry center of Europe, the latest battleground for populists eager to bring down both Chancellor Angela Merkel of Germany and the idea of a liberal Europe itself.
Rich, religious and on the southern border, Bavaria is the Texas of Germany. It is a conservative bastion of the nation most associated with Europe’s open-door migration policy and the ultimate prize in a culture war that has seen populism chip away at consensus on the eastern flank of the 28-member bloc.
Since the 2015 migration crisis, the far right has been steadily gaining support in Bavaria, and local conservatives have responded by veering sharply to the right themselves.
The number of asylum seekers arriving at Bavaria’s land border is but a fraction of what it was three years ago. But in the past two weeks, the Christian Social Union, a longtime ally of Ms. Merkel’s conservatives, has mounted a spectacular rebellion against the chancellor. It is demanding a hard border with Austria and threatening to pull out of her government.
A last-minute deal with European partners on Friday may be enough to save Ms. Merkel’s fractious coalition — for now.
But the Bavarian mutiny has already left its mark in conservative circles north of the border, increasingly divided themselves and watching closely whether the Bavarian strategy works. Bavaria has become a test case for how to win back voters from the far right even if the price is to move right and close ranks with populists in neighboring countries.
Viktor Orban, the semi-authoritarian prime minister of Hungary, has been a regular guest of honor of Bavaria’s conservatives, as has Sebastian Kurz, the chancellor of Austria who governs in a coalition with the far right. There is talk of “an axis of the willing” that also includes Italy’s new far-right interior minister, Matteo Salvini.
Markus Söder, the Bavarian premier, speaks of the end of “orderly multilateralism,” and has ordered that Christian crosses be displayed in every state government building. From July 1, a Bavarian border force will start patrolling along a border that is supposedly open under Europe’s border-free travel.
Alexander Dobrindt, the Bavarians’ parliamentary leader in Berlin, predicts a “conservative revolution.”
“Populism has arrived at the heart of Europe,” said Timothy Garton Ash, professor of European history at Oxford University. “You now have a major European party endorsing the Orban program on migration.”
Bavaria may seem an unlikely home for populism. Nearly a third of Germany’s blue-chip listed companies are based here, unemployment is below 3 percent and economic growth has exceeded that of other German regions for the past eight years.
A melting pot of Slavic and southern European influences for centuries, Bavaria has also been more successful than many other German regions at integrating newcomers. Munich, for example, is far more multicultural than Berlin.
As Wolfgang Jirschik, mayor of Baierbrunn, a small village in the Isar valley near Munich put it: “There is no need to make Bavaria great again. It is already pretty great.”
But as in neighboring Austria, Bavaria’s affluence has not inoculated it against a powerful populist narrative that has entered an increasingly defensive mainstream: that despite falling numbers the migrant crisis is continuing, that Ms. Merkel is to blame and that migrants threaten the traditions, prosperity and stability that have been the backbone of Bavarian identity.
“This is not about economics,” said Gerald Knaus, the director of the European Stability Initiative, a Berlin-based think tank. “It is about identity and a very successful populist P.R. machine that is rewriting recent history.”
In the fall of 2015, Bavaria was on the front line of Germany’s migrant crisis, processing tens of thousands of newcomers a day along its 500-mile border with Austria and earning worldwide praise for the humanity and efficiency with which bureaucracy and volunteers worked hand in hand to meet the challenge.
Refugees were welcomed with applause at train stations. Sport halls were transformed into makeshift camps. Soup kitchens were manned by local residents.
But three years later, the mood has shifted, particularly in areas close to the border where the far-right Alternative for Germany, or AfD, has made the most of its gains.
“Our perfect world was shaken,” said Hans Ruppenstein, 76, a member of a local shooting club in Baierbrunn. “People have become scared.”
Of what, exactly, no one is quite sure.
The only problems with refugees in Baierbrunn have involved complaints about garbage and noise, the mayor’s office reports. And once, a refugee who took his bike onto the autobahn.
But the AfD, long associated with the economically depressed regions of the former Communist East, has found fertile ground in largely Roman Catholic Bavaria, stoking diffuse fears of Islamization and warning of migrant crime and terrorism. The occasional shocking headline, like that on a failed asylum seeker who severely injured an emergency doctor with a bottle last week, reinforces a sense of growing insecurity.
Take Deggendorf, a picture-perfect town on the Danube near the Czech and Austrian borders. In the fall of 2015, local residents saw tens of thousands of migrants pass through. Now, only about 300 asylum seekers remain in the town of 36,000.
Deggendorf has full employment and hardly any crime. But it registered the highest vote for the AfD in western Germany in last year’s national election.
“Burqa?” one of the AfD’s election posters had asked on a photo depicting three German women in dirndls. “We prefer Burgundy!”
Katrin Ebner-Steiner, a local AfD politician, likes to mock the conservatives for stealing her party’s policies.
“The AfD is making itself felt,” she said one recent afternoon, smiling contentedly, before adding: “Voters are no fools. They can tell the copy from the original.”
In some ways, Bavaria is an obvious target for the far right. Nationalism comes more easily to people in this proud former kingdom that has nurtured its distinct identity over centuries.
In the 19th century, resisting Prussian dominance, the Bavarian king paid couples to marry in traditional garb. More recently, the state government in Munich created a ministry for “heimat” — a term that stands for homeland, belonging and geographic rootedness — celebrating local folklore and shifting jobs and investment from urban centers to rural areas.
Hitler started his political career in Munich. But like Austria, Bavaria has managed to somewhat distance itself from that part of German history.
“Bavarian nationalism has been a tolerated form of nationalism since 1945,” said Klaus Reichhold, who runs a cultural institute in Munich and has written about Bavarian folklore. “You could always bypass the German taboo on nationalism by being Bavarian.”
Birgid Ley, an independent local councilor in a suburban district of Munich, said she always tells people abroad she is from Bavaria rather than Germany.
“When you say you’re Bavarian, people think of beer and castles, not the Nazis,” said Ms. Ley.
Germans north of the border sometimes have trouble understanding Bavarians, and not just because of the distinctive local dialects.
Bavaria has been more consistently conservative than the rest of the republic. The Christian Social Union has been in power here since 1957 and has lost its absolute majority only twice in nearly half a century.
“The democratic culture in Bavaria is not as developed here as it is elsewhere in Germany,” where conservatives and Social Democrats traded power several times, said Mr. Reichhold.
The conservatives have never been shy to veer right: The much quoted mantra of their most iconic postwar leader, Franz-Josef Strauss, was to never allow a party to the right of the conservatives to become electable.
That, too, explains the current strategy in conservative ranks to fish for votes on the far right.
So far, it is unclear whether the gamble will pay off or simply help cement the support base of the AfD. Opinion polls suggest that a tougher line on border security is popular — but the political jockeying of the conservatives ahead of state elections in October is not.
The fact that the AfD has been gaining momentum at a time of strong economic growth is particularly worrying, said Mr. Jirschik, the mayor of Baierbrunn. “What happens when the economy slows again?”
Mr. Jirschik worries about freedom and democracy, as well as a social consensus he fears is wearing thin. He saw the outpouring of sympathy for the refugees in 2015, the volunteer army of helpers, the good will. But the memories are fading.
“When I see these developments and this new language, I am afraid,” Mr. Jirschik said. “When I see how quickly it happened elsewhere, in America, in Poland — I do ask myself: Could this happen here to us?”