VIENTIANE, Laos — President Obama has grown accustomed to having his foreign travels overshadowed by terrorist attacks or police shootings. This might be the first time one of his trips has been marred by bad manners.

On his final visit to Asia as president this week, Mr. Obama had intended to confront America’s wartime legacy in Laos and to reaffirm his strategic pivot to the region. Like all presidential trips, it has been meticulously planned to showcase achievements: a climate-change partnership with China and vigorous American engagement with China’s neighbors.

But in four messy days, the president lost the clear message choreographed by his advance team. There was the chaotic arrival ceremony in China, in which missing aircraft stairs unexpectedly trumped the theme of global warming. And then, an ugly personal outburst that prompted Mr. Obama to cancel a meeting with the new leader of the Philippines, an ally the United States will need in the coming contest with China for regional influence.

On Tuesday, the White House scrambled to limit the fallout from skipping a meeting with Rodrigo Duterte, the Philippines’ president. Mr. Obama pulled the plug after hearing that Mr. Duterte had unleashed a profane diatribe against him, threatening to repeat it to Mr. Obama’s face if he dared ask him about recent extrajudicial killings in his country.