For all its epic warfare and upheaval, the 20th century did produce one happy ending: the emergence of the Federal Republic of Germany as the first German state in modern history that was united, democratic, secure, prosperous and peaceful.

And so, when hundreds of thousands of refugees flocked to Europe from Syria and other distressed places in the summer of 2015, German Chancellor Angela Merkel framed her decision to admit them as a chance to bring her country’s postwar spirit of achievement to bear in favor of needy newcomers others in Europe had shut out.

“Germany is a strong country,” she declared. “The motive with which we approach these matters must be: We have done so much — we’ll get this done!”

This would have been a bold gesture in any political culture. In postwar Germany, where acts of risk-taking political leadership had been frowned upon, even for ostensibly good causes, Merkel’s move was downright dramatic.

It hasn’t panned out. Millions of Germans did volunteer to help refugees, as she asked, often with good results. Millions of other Germans recoiled, however, as costs and social disruptions mounted — including cases of sexual assault and murder by newcomers, and, even more frightening, terrorism.

German Chancellor Angela Merkel reiterates her position on burqas, telling her conservative CDU that "a full veil is inappropriate in our country" and "should be banned." (Reuters)

Merkel’s poll numbers plunged. The right-wing Alternative for Germany (AfD), an anti-immigration party similar to France’s National Front, previously barely an asterisk in the polls, has surged to the point where 1 out of every 8 Germans supports it.

Instead of a case study in the efficacy of moral leadership, Merkel’s decision looks more and more like a case study in the costs of good intentions. At a time when the world badly needs a stable, confident Germany, her decisions fractured the rock upon which that stability and confidence have rested since World War II: domestic political consensus mediated by broad-based political parties.

Consequently, six parties — stretching from the AfD on the ultra-right to the former East German communists on the far left — are now in position to win 5 percent of the vote in next year’s election for a new Parliament, the minimum for gaining seats. That’s not counting the grumbling within Merkel’s own centrist ruling coalition — or the general rise in American-style political incivility, which has unsettled an aging society that prizes order almost to a fault.

This may seem an unduly harsh judgment against a chancellor who — to repeat — tried to do the right thing, under great pressure, at a time when European media were dominated by images of desperate men, women and children fleeing the horrors of war.

Still, it is an assessment Merkel herself seems to acknowledge in hindsight, albeit only by implication. “A situation like the one in the late summer of 2015 cannot, should not and must not be repeated,” she told her Christian Democratic Union party’s annual conference Tuesday, to thunderous applause.

She also promised that many of the people Germany admitted will be sent back, and that those who stay will not be permitted to develop a “parallel society.” As if to dispel any doubts as to what sort of parallel society she had in mind, she advocated the widest permissible ban on the burqa, the full-body veil worn by some Muslim women, adding: “Our law takes precedence before tribal rules, codes of honor and sharia.”

In other words, Merkel now finds herself cribbing some of the populist right’s agenda, to placate an electorate of which 40 percent agree with the statement “Islam is undermining German society,” according to a new Friedrich Ebert Foundation survey.

The likeliest political outcome in Germany, where most people still express sympathy for refugees perceived as genuinely in need of help, is that Merkel and her allies will manage to remain in power, albeit possibly on a narrower basis. As the flow of migrants has halted in recent months, her approval ratings have improved.

Of course, this respite was achieved with the help of Turkish strongman Recep Tayyip Erdogan, who agreed with Merkel to stop refugees from going to Europe via his country in return for $6.3 billion in aid and — critics plausibly assert — Germany’s indulgence regarding his regime’s suppression of human rights.

As if to remind Merkel that she is beholden to him, Erdogan recently threatened to revoke the deal and reopen the migratory floodgates, in response to what the dictator in Ankara regarded as a slight by the European Parliament.

Merkel’s unholy alliance with Erdogan, like her Tuesday announcement of a hard, new line on immigration and assimilation, may seem jarring to those who had begun to speak of the German chancellor as the last, best hope of liberal-democratic values amid the West’s tide of right-wing populism exemplified by President-elect Donald Trump.

A more realistic lesson might be this: No government can do more good than it can sustain politically.

Read more from Charles Lane’s archive, follow him on Twitter or subscribe to his updates on Facebook.