Germany has long occupied an exceptionally comfortable place in the world. It has an export-dependent economy, selling its cars and machines far and wide — and many tanks and submarines, as one of the world’s largest arms exporters. But when it comes to countering perceived security threats — whether the Islamic State or Putin — it has allowed allies to take the lead. German leaders sent troops to Afghanistan but largely avoided referring to it as a “war,” even as German soldiers engaged in ground combat there for the first time since World War II. Germany’s aversion to military power has been sustained by one glaring fact: Its defense is guaranteed by the world’s pre-eminent superpower, the United States, within the framework of NATO. President Donald Trump, who tended to reduce foreign policy to questions of who was ripping off whom, was particularly obsessed with what he saw as German defense freeloading, calling Germany “delinquent” on military spending. But it wasn’t just Trump. Every recent U.S. administration tried, and mostly failed, to get the Germans and other European allies to strengthen their militaries and meet the NATO defense-spending target of 2 percent of gross domestic product, a goal Germany has long undershot.

Even as Putin’s rhetoric and actions became increasingly bellicose, a mantra of “Wandel durch Handel,” or “change through trade,” continued to define Germany’s foreign policy toward Russia. Economic interdependence with Russia, the thinking went, would encourage Russian democratization, or at the very least a rules-based international order that precluded acts of aggression. It was also good for business. By 2015, Putin’s imperial ambitions were becoming increasingly clear. Yet German officials backed the new Nord Stream 2 pipeline that would bring Russian natural gas to Germany directly through the Baltic Sea, bypassing existing pipelines in Ukraine. (Nord Stream 1, running the same route, opened in 2011.) The Germans pursued the project despite warnings from U.S. lawmakers, who feared that German dependence on Russian gas gave Putin leverage. Those lawmakers, along with leaders of Eastern European countries who were increasingly alarmed by Putin’s aggression, also worried that the new pipeline would compromise Ukraine’s security, isolating it and depriving it of lucrative transit fees for transporting gas from Russia to Europe.

Revenue from German fossil-fuel purchases helped the Kremlin finance a military expansion. At the same time, German military spending as a portion of G.D.P. remained near a post-World War II low. Leaders of Eastern European countries like Poland and Ukraine — which have endured the great geographic misfortune of being sandwiched between Germany and Russia and suffered immensely under both Hitler and Stalin — grew exasperated with Germany’s approach to Russia. Even as far back as 2006, Poland’s then defense minister, Radoslaw Sikorski, likened plans to build the first Nord Stream pipeline to the 1939 Molotov-Ribbentrop pact — the nonaggression agreement between Nazi Germany and the Soviet Union that divided Eastern Europe into spheres of influence. “Poland has a particular sensitivity to corridors and deals above our head,” Sikorski said at a security conference in Brussels. “That was the 20th century. We don’t want any repetition of that.”

As far as Germany was concerned, history had shown that soft-power accommodation was more effective than hard-power intimidation. Wandel durch Handel was in many ways an extension of West Germany’s Cold War Ostpolitik, a policy of rapprochement with Russia put in place by the Social Democratic government at the end of the 1960s, amid fears of nuclear war. Though West Germany then maintained a robust military to deter a Soviet invasion, West German leaders came to believe that economic interdependence was crucial to preventing an apocalypse. In a now-familiar pattern, pipelines were built to bring Soviet natural gas to Germany. Over the years, American presidents expressed concern that Germany was becoming too dependent on the Soviets and providing revenue for their military. But in Germany, Ostpolitik was seen, especially on the political left, as instrumental in ending the Cold War.

When Russia invaded Ukraine in February, the failings of German policy became clear even to Germans: Germany’s army consisted of an aging force of about 183,000 troops. German soldiers lacked not only heavy weapons and ammunition, but also basics like protective vests, helmets and backpacks. On the day of the invasion, Lt. Gen. Alfons Mais, the head of the German Army, one of three branches of the Bundeswehr, used his LinkedIn page to broadcast his frustration. “The army that I am privileged to lead is more or less bare,” Mais wrote. “This does not feel good!” In April, President Frank-Walter Steinmeier, a Social Democrat who served as foreign minister under Angela Merkel and was an architect of Germany’s Russia policy, admitted to mistakes. “We held on to bridges that Russia no longer believed in and that our partners warned us about,” he told journalists in Berlin. “We failed at building a common European house that includes Russia.”

Few countries have been as fundamentally shaken by the Russian invasion as Germany. Soaring energy costs are undermining German industries. Wandel durch Handel has been discredited, calling into question not only Germany’s past Russia policy but also its current relationship with an autocratic China — Germany’s largest trading partner — at a time when President Xi Jinping is consolidating power and China is building up its armed forces and threatening military action against Taiwan. Germany’s leaders are now frantically seeking new energy sources and arguing for the necessity of hard power.

As part of his Zeitenwende speech, Scholz vowed to meet the NATO defense-spending target “from now on,” though his government has since been noncommittal about when that might happen. In part, this is because of the entrenched bureaucracy that makes the process of spending money on arms glacially slow. Should German leaders deliver on their promises, Germany would become the third- or fourth-biggest military spender in the world. Before the war, such an increase would have been highly unpopular. But in a poll conducted for German public television soon after the invasion, 69 percent of Germans supported it.