Just two months ago, Germany was suffering from yet another image problem, deplored as a harsh and heartless overlord in its effort to impose financial discipline on its European neighbors.
Its hard-nosed bailout negotiations with debt-ridden Greece and apparent willingness to throw Athens under the bankruptcy bus triggered protests around the world and caricatures of Chancellor Angela Merkel as Adolf Hitler.
Now Merkel is being hailed as an angel of mercy and her country as a paragon of virtue for flinging open the doors to a massive influx of refugees. The sight of Germans whooping in welcome and thrusting gifts at bedraggled asylum seekers arriving on chartered trains has stood in sharp contrast to the indifference or outright hostility directed at them in other European nations.
Some Germans hope that such positive images might help remove some of the stains on their reputation, including older, darker associations with trains full of unwanted people — those who were systematically sent to their deaths by the Nazis. Merkel said she was moved by the sight of hundreds of migrants stuck at a railway station in Hungary last week, chanting their desire to come to Germany.
See the most-read stories this hour >>
"This wasn't always the case," she said with characteristic understatement.
More recently, Berlin has been cast in the familiar role of villain for taking a tough line on Greece and on debt in the Eurozone.
"Some started saying that we are financially overtaking Europe … and that we are only thinking of our own interests," said Jonas Walther, a 25-year-old choreographer. "Now everybody is praising Germany for its intake of refugees.
"But we should not be taking refugees to improve our image," he added. "We should be taking them because of the humanitarian situation, and I think that this is currently the case."
German officials say they are prepared to accept as many as 800,000 asylum seekers this year, a number equal to 1% of the population. The government announced Monday that it would set aside $6.7 billion next year to deal with the influx.
France and Britain also said Monday that they would increase the number of refugees they would accept.
British Prime Minister David Cameron said that his country would take in 20,000 Syrian refugees within the next five years, and French President Francois Hollande pledged to admit 24,000 asylum seekers in the next two years.
"We will do this because I believe it is a principle which France is bound by," Hollande declared in Paris.
NEWSLETTER: Get the day's top headlines from Times Editor Davan Maharaj >>
Merkel said that the public outpouring of donations and assistance to refugees who arrived by the thousands in Germany over the last few days ought to make her compatriots feel "proud and grateful."
But there's unease here as well: over how far the country's resources can be stretched, over the backlash already brewing in some areas and over Germany's being a leader and an outlier in the crisis, even if laudably so.
Despite all the praise for its generosity toward refugees, the government in Berlin feels far more comfortable acting in concert with other European nations, precisely in order to avoid accusations of German high-handedness or exceptionalism. But the country's economic might has turned it into first among equals in the EU whether it likes it or not.
"Germany is very reluctant in accepting a leadership role," said Alexander Goerlach, editor of the European, a magazine here in Berlin. "This is due to Germany's past. We are haunted by the ghosts and demons of the nationalistic era of the 19th century that in one way or another laid the ground for the two world wars."
Merkel is working with the EU's other main power, France, to come up with a solution to the biggest migrant crisis to hit the region since World War II. The two partners have agreed on a proposal, to be unveiled Wednesday, to distribute 120,000 asylum seekers among EU nations based on each country's size and economic strength.
But agreement among all 28 EU members appears elusive, with several Central and Eastern European states saying categorically that they do not want to accept any refugees. Hungarian Prime Minister Viktor Orban, whose heavy-handed treatment of asylum seekers has drawn international criticism, dismissed the quota plan Monday, saying that residents' right to free movement within the EU would make country-specific numbers unenforceable.
Hundreds of refugees and migrants continued to push their way north from the Balkans into Hungary en route to their preferred destinations of Germany and Sweden. They broke out of a receiving center on the Hungary-Serbia border, then began walking north along one of Hungary's main highways, the Associated Press reported.
More asylum seekers, many from Syria and Iraq, also continued to land in Europe on one of Greece's eastern islands. More than 230,000 have come ashore to date, including 61 rescued Monday off the coast of the hard-hit island of Lesbos. Among those plucked from the waters were a baby and more than a dozen other children.
More than 15,000 refugees and migrants are living in squalid conditions on Lesbos, waiting to be processed. A Greek official said that about two-thirds of them would be ferried over to the Greek mainland this week. Athens has appealed to the EU for emergency aid to deal with the influx.
With no hint that the flood of arrivals would abate any time soon, the southern German state of Bavaria, the point of entry into the country for most refugees, began exhibiting signs of strain. About 20,000 asylum seekers arrived in Germany over the weekend, and Bavarian officials said at least 2,500 more arrived Monday, leaving them scrambling to find shelter for each new batch.
"We will still do our best to create new places," Christoph Hillenbrand, the president of the government of Upper Bavaria, told reporters at the train station in Munich, the state capital. "But we are pushing up against the limit now."
Although polls show a strong majority of Germans in favor of accepting refugees, Merkel's influential political allies in Bavaria warned that assistance to newcomers could not be unlimited.
In a bow to their concerns, Merkel agreed Monday to reduce the amount of cash given to refugees and to increase the amount of in-kind aid instead. Lawmakers will also introduce measures to make it easier to deport people deemed to be economic migrants and not refugees.
Some Germans who disagree with their government's generosity, including suspected neo-Nazis, have done so violently, burning down facilities intended for migrants and staging angry protests. Five asylum seekers in southwestern Germany were injured Monday when the house in which they were living caught fire, German media reported. The cause of the blaze was unclear.
But such incidents have been drowned out in recent days by the numerous accounts and images of ordinary Germans turning out in droves to help the newcomers in their midst.
In Munich, such efforts shifted into high gear at a donation bank, where half a dozen people sorted through heaps of clothing, toys, bicycles and bedding earmarked for refugees. The welcoming attitude was particularly noteworthy in a city that has long had to live with the stigma of being the birthplace of the Nazi Party.
"This is the nicer side of Germany you are seeing," said retired banker Eddie Lauer, 64.
Filmmaker Doris Doerrie said that the spontaneous gestures of goodwill undoubtedly benefited the country's reputation abroad.
"Germany does worry about its image," she said. "But I worry a little about us getting too full of ourselves, applauding our actions. We shouldn't get carried away by the idea of our own goodness."
Times staff writer Laura King in Munich and special correspondents Amro Hassan in Berlin and Christina Boyle in London contributed to this report.
Follow @HenryHChu on Twitter for news out of Europe
MORE ON EUROPE'S MIGRANT CRISIS: