NATO ambassadors gathered Thursday morning for an emergency meeting in response to Russia’s invasion of Ukraine with a pledge to defend alliance members and support Ukraine, which isn’t a member.

Russia’s attack on Ukraine, which since 2008 has had an invitation to potentially join the alliance, has breathed new life into the North Atlantic Treaty Organization, the U.S.-led military alliance created in the ashes of World War II to square off with Moscow.

NATO Secretary-General Jens Stoltenberg said alliance members “stand with the people of Ukraine at this terrible time” and called Russia’s assault “a grave breach of international law, and a serious threat to Euro-Atlantic security.”

The war for Ukraine has rallied NATO’s 30 members around a shared assessment: After a quarter-century of relative peace, Europe’s security can no longer be taken for granted.

In response to Russia’s recently increasing aggression toward Ukraine, the U.S. and allies have been beefing up their military presence in the NATO countries that border Russia—Poland, Lithuania, Latvia, Estonia—whose hawkish views on Russia once struck Western allies as a relic of the Cold War. Romania and Bulgaria, newer NATO members that face Russia across the Black Sea, have also recently welcomed additional troops and equipment from allies to the west.

The support means that Russian President Vladimir Putin, who has justified his campaign against Ukraine partly as a response to NATO’s encroachment of Russia’s borders, faces an escalation of allied forces next to Belarus, which Russia is slowly subsuming, and Ukraine, which it now aims to dominate.

Spanish and French warships are cycling through the Black Sea. A flow of new arms sales is under way, with Washington selling sophisticated Abrams tanks and F-35 jet fighters to Poland and giving allies in Eastern Europe the green light to sell U.S.-made Javelin antitank missiles to Ukraine.

Just months ago, the alliance was stung by a chaotic defeat in Afghanistan, having spent 20 years trying to rout the Taliban and build up the Afghan army. NATO was mulling a jumbled set of priorities, from combating Islamist terrorists to containing China’s rise, while a fringe of right-wing and Moscow-friendly leaders from Hungary or the Czech Republic pushed for the alliance to tackle illegal migration.

For now, those voices have been drowned out, as NATO focuses squarely on the risk of conflict spilling over from the war on its doorstep. Talk of the alliance playing a greater role assisting America’s rivalry with Beijing has been put on hold—a point of frustration for Washington, where officials have lamented the time and attention spent shoring up the security of Europe, instead of enlisting the bloc’s help against China.

France, whose President Emmanuel Macron once pushed for a “true, European army” that could fight with or without U.S. help, has softened that rhetoric.

All the same, NATO’s renewed unity could prove short-lived, if the conflict ends quickly—or runs long enough to inflict painful disruptions to the Russian gas that Europe depends on. In Central Europe, suspicion runs deep that Western allies don’t have the stomach for a long struggle against Russia, especially if it hits consumers’ gas bills.

In a poll published this month, only 35% of Germans deemed defending Ukraine’s sovereignty worth the risk of an economic downturn; 38% considered it wasn’t worth the risk, according to the European Council on Foreign Relations, which conducted the survey. In France, just 31% of people felt it was worth the risk, with 41% opposed.

For years, successive U.S. administrations fretted that Washington’s biggest allies in Europe had grown complacent over 30 years since the Cold War’s end, reluctant to spend on their own defense and accustomed to life under the U.S. security umbrella. European allies doubted whether NATO had a clear and relevant purpose.

“What we are currently experiencing is the brain death of NATO,” Mr. Macron said in a 2019 interview.

European leaders had been frustrated with Washington after last year’s retreat from Afghanistan, which came nearly two decades after the Sept. 11, 2001, attacks that prompted the first and only use of NATO’s collective-defense clause. NATO’s 2011 air campaign that helped topple Libya’s Moammar Gadhafi set off a refugee crisis that energized nationalist leaders in Europe who have been persistent gadflies for NATO—from French presidential candidate Marine Le Pen to Hungarian Prime Minister Viktor Orban.

Washington and Berlin had been at odds over Germany’s reluctance to raise military spending, cut imports of Russian natural gas and join the U.S.’s hardening stance on China.

For the moment, the conflict in Ukraine buries those disagreements and offers a chance to find common cause.

Germany has halted Nord Stream 2, its gas pipeline with Russia—and military spending across the alliance is rising. The invasion of Ukraine is likely to accelerate that trend. Hawkish views on Russia, once concentrated in Europe’s east, have gained ground in Berlin and Paris.

The military confrontation “changes things in a pretty fundamental way,” said Ivo Daalder, U.S. ambassador to NATO from 2009 to 2013. “I think it’s the wake-up call that war is not just something that happens far away but it’s something that happens in our neighborhood.”

Mr. Daalder predicted that NATO members would rally behind efforts to cut European reliance on Russian gas. “I bet that Nord Stream 2 will never have Russian gas flowing through it,” he said.

That said, the alliance, which does much of its work through decisions that require unanimity, still has marginal leaders who have tried to thwart NATO’s support for Ukraine, such as Croatian President Zoran Milanovic, who has demanded Croatia remain apart from any conflict with Russia.