President Trump’s first NATO meeting was the moment to show that he would honor the example of his predecessors in leading a strong and unified alliance that has been and should remain the anchor of Western security. He failed.

Instead of explicitly endorsing the mutual defense pledge at the heart of the alliance, Mr. Trump lectured the members for falling short on pledges to spend 2 percent of their gross domestic products on the military, much as he had hectored them on this subject during his presidential campaign.

There were signs, too, that Mr. Trump and the allies remain at odds over Russia, which is deeply unsettling given mounting questions about Russian interference in the 2016 presidential election.

Mr. Trump has a point when he says the allies should increase their military budgets, which they have started to do, partly in response to Russia’s 2014 invasion of Ukraine. But his obsession with the matter has reinforced the impression that he sees NATO as essentially a transactional arrangement, not as an indisputably important alliance that has kept the peace for 70 years and whose value cannot be measured in dollars and cents. Against this history, Mr. Trump’s repeated scolds are not just condescending but embarrassing.

What possesses him to treat America’s allies so badly? The NATO nations are mostly democracies with vibrant free markets that have helped America keep enemies at bay, including in Afghanistan. The question is made all the more pressing in view of Mr. Trump’s enthusiastic embrace of countless autocrats, among them Vladimir Putin of Russia and King Salman of Saudi Arabia, where he just paid a deferential visit and assured Sunni Arab leaders that “we are not here to lecture” despite their abominable records on human rights.

This perplexing dichotomy has been vividly captured in video and photographs — Mr. Trump laughing comfortably with Russia’s foreign minister and ambassador to Washington during a recent Oval Office meeting, while refusing to shake the hand of Chancellor Angela Merkel of Germany when she came to town. There was more of the same in Brussels, with Mr. Trump shoving aside the prime minister of Montenegro, which recently defied Russia to join NATO, on his way to a front row spot for a photograph.

The allies had hoped to hear a robust endorsement of the NATO Treaty’s Article 5, which commits them to a “one-for-all, all-for-one” principle that has been the foundation of the alliance since it was established. What they got instead was a vague promise to “never forsake the friends who stood by our side” after the Sept. 11 attacks, and assurances from Sean Spicer, the press secretary, of a “100 percent commitment to Article 5.”

This would have been more persuasive coming from Mr. Trump, since he and not Mr. Spicer had denigrated NATO as “obsolete” and suggested darkly that the United States might not defend allies under attack if they did not contribute more to the alliance.

Secretary of State Rex Tillerson has been no more credible than Mr. Spicer. “Of course we support Article 5,” he told reporters earlier this week, presumably assuming that the president would say much the same thing in Brussels. That Mr. Trump did not reinforces the common perception that Mr. Tillerson has no more influence over his thinking than do Jim Mattis, the defense secretary, and Lt. Gen. H. R. McMaster, the national security adviser, on whom many had counted to put Mr. Trump’s foreign policy on a more responsible path.

That Mr. Trump and the allies were unable to agree on a common approach toward Russia was also worrisome. Moscow has become increasingly aggressive as Mr. Putin annexed Crimea, waged war in eastern Ukraine, meddled in the American and European elections and intervened militarily in Syria. The most that emerged from a meeting between Mr. Trump and Donald Tusk, president of the European Council, was that the two shared the “same line” on Ukraine.

All told, Mr. Trump’s commitment to NATO and America’s tradition of leadership remain very much up in the air. Should the president abdicate both, no one would be happier than Vladimir Putin.