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.