In September, Angela Merkel visited an asylum center in Spandau, near Berlin. The refugees greeted the German leader as if she were their savior, pressing close for selfies with her. Merkel does not usually take kindly to unsolicited male hugs. But this time she posed gamely and flashed winning smiles.

What made the chancellor a heroine to the refugees was a decision she had taken only days earlier.

Thousands of people trudging through the Balkans toward northern Europe were stranded in Hungary in precarious conditions. Empathizing, Merkel temporarily ignored the European Union's asylum agreements, which say that the member state in which refugees first arrive must process their asylum requests. On her command, Germany opened its borders to the refugees. Coming via Austria on foot, bus and train, more than 20,000 arrived in the first weekend of September alone.

At first, many ordinary Germans greeted them in a euphoric mood. But others in Germany and across Europe were taken aback. There has since been a marked backlash against the August Willkommenskultur whose spirit Merkel captured and encouraged, with those Spandau selfies held up as reckless enticements for yet more Syrians and others to join the 1 million refugees now expected in Germany this year.

Merkel at first seemed surprised by the sudden turn in public opinion. But she has since turned defiant and bold, as if inspired by a clear moral purpose.

Having been governed by her for 10 years, Germans thought they knew Merkel. Whereas her predecessor, Gerhard Schröder, was dubbed the "basta chancellor" for his brash assertiveness, Merkel was valued, if often also criticized, for her caution. Her governing was a "politics of small steps," lampooned for endless hedging and "leading from behind." To widespread surprise and some unease, though, the chancellor has been transformed. She has found a new voice that is simple and strong. "If we start having to apologize for showing a friendly face in emergencies," she says, "then this is not my country."

The change in style reflects the nature of the new challenge. A lot of Merkel's decade in power has been taken up with the international demands of what might be called crisis management, had the problems involved not become chronic: the financial troubles in the eurozone, especially Greece; the confrontation between Vladimir Putin and the West; the specter of a British exit from the E.U. Preoccupied with these international worries, she stuck to small-bore fiddling at home, and the Germans forgave her. The acceleration of the refugee crisis, though, merges international and domestic demands into one daunting task.

There are four main reasons for Merkel's central role. First, she governs at a time when other European leaders seem weak or even absent and America's interest in solving European problems is on the wane. Second, she has no credible challenger within Germany. Third, Germany is the biggest and strongest economy in the E.U. Fourth, Merkel has proved adept at crisis diplomacy. At home or abroad, she has a knack for dealing with complicated, vain or macho men, from Putin to Turkey's Recep Tayyip Erdogan.

Now two more of Europe's many difficult men threaten to undermine her stature. One is Viktor Orban, the illiberal Hungarian prime minister whose answer to the refugees has been barbed-wire fences.

More surprising are the attacks by Horst Seehofer, the premier of Bavaria, the state through which most refugees enter Germany, and also head of the Christian Social Union (CSU), the regional sister party to Merkel's national party, the Christian Democratic Union (CDU). These two parties sit as one group in the Bundestag and are usually reliable conservative allies. There is a long CSU tradition of sniping against the federal government to assert the interests of Bavaria. But CSU leaders usually stop short of damaging CDU chancellors.

This time is different. In September, Seehofer called Merkel's embrace of the refugees a big mistake. He then invited Orban to a CSU gathering as guest speaker and smiled as the Hungarian railed against the chancellor.

Seehofer's rebellion has spread in attenuated form to Merkel's own party. In October, 34 regional CDU politicians complained in an open letter that her "policy of open borders accords with neither European and German law nor with the program of the CDU."

Polls confirm a turn in public opinion. Support for the Union parties has dropped 7 percentage points since the summer and is at its lowest point since 2012. Yet this slide should not be exaggerated. Among members of the CDU, only one in three takes Seehofer's side on what to do about refugees, while 57 percent stand with the chancellor.

Her personal support is even higher. One recent poll found that 82 percent of Christian Democrats approve of her leadership and 81 percent want her to run for a fourth time at the election due in 2017.

The ultimate causes of the refugee crisis are neither Merkel's fault nor in her control. She can't end the civil wars and proxy conflicts in the Mideast. But her legacy will be determined by whether she can hold together Germany and the E.U. as they absorb this shock. For a woman who spent half her life behind the intra-German wall, a Europe of fences and barbed wire would be a failure. Keeping Germany open and tolerant inside an E.U. true to its humanitarian founding values isn't her policy. It is her mission.

Copyright 2013 The Economist Newspaper Limited, London. All Rights Reserved. Reprinted with permission.