Mr. Trump seems unbothered by the ostracism, making the case that America has allowed itself for too many years to be pushed around by foreign powers that took advantage of it. In some ways, he wears the criticism from abroad as a badge of honor, proof that he is representing the best interests of the United States. Supporters cheer his aggressive posture on the world stage.

Mr. Trump had already made clear before the Group of 7 summit that he had no intention of reconsidering his position on climate change or Iran. And he refused to ease steel and aluminum tariffs he just imposed on Europe and Canada, arguing that the allies have been dealing with the United States unfairly.

“There are disagreements,” Larry Kudlow, the director of Mr. Trump’s National Economic Council, conceded at one point during the summit meeting. “My view? We can get through this.”

No one got through it this weekend, however. Mr. Trump signaled his disdain for the Group of 7 meeting by arriving late and leaving early. During closed-door meetings on Friday, he went around the room, citing ways each of the other nations represented there had mistreated the United States in some fashion or another, according to a European official.

Just hours before Mr. Trump’s outburst, a senior administration official said the meetings had been less contentious than depicted and that the session with Mr. Trudeau in particular had been much better than anticipated. The official, who insisted on anonymity to describe closed-door discussions, predicted the United States would sign the final communiqué.

But Mr. Trump, while en route to Singapore, evidently watched or was briefed on a news conference Mr. Trudeau held afterward and was offended by the Canadian’s defense of his country’s trade policies.