“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. Reichold.

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.