The scandal captures Germany at a moment when it has been trying to hold on to values it always saw as defining, but that have become increasingly difficult to maintain as it becomes drawn into the messy problems of Europe and the world.

The Volkswagen blow came after months in which Germany seemed to go out of its way to bolster devotion to rules and order by imposing austerity and other measures on Greece, as a condition for a third bailout from its financial crisis. Berlin insisted that European partners stick to what it said were the rules of the euro currency union, that there could be no transfer of debt from one member nation to the 18 others in the eurozone.

Yet no sooner was it gaining a reputation in Greece and in other southern European nations as, at best, a strict task master and, at worst, a heartless bully, than Germany and its chancellor, Angela Merkel, were transformed.

By opening its doors to migrants from Syria and other troubled spots in the Middle East, admonishing other European nations to do their fair share and showcasing its immense volunteer network to make the newcomers feel welcome, it has in recent weeks been seen as the soft heart of Europe — a reputation it seemed to cherish, given its history.

But for all Germany’s pride in efficiency and rectitude, that nation’s vulnerability was exposed this year when the co-pilot of a Germanwings jet crashed into a French mountainside, deliberately killing himself and the other 149 people on board.

The chairman of Lufthansa, Germanwings’ parent company, initially insisted that the company had done everything right, and that there was no way that it could have foreseen the suicidal tendencies of the co-pilot.

But after it became clear that the pilot had been given a leave during training to deal with psychological issues, Lufthansa’s chairman, Carsten Spohr, backed down and apologized. “That this happened precisely to us, we are very sorry for,” he said.