Mr. Trump traveled almost 7,000 miles to become the first foreign leader to meet with Emperor Naruhito since his enthronement this month. The president’s closest ally on the world stage, Mr. Abe, regaled him with golf, a sumo tournament, a cheeseburger lunch and a robatayaki dinner, hoping to cement what the prime minister described as their “unshakable bond.”

Throughout his visit, though, Mr. Trump acted like a man who could never be fully present. From start to finish, his stay in Japan was defined more by his focus on politics at home than diplomacy abroad, expressed as a running refrain posted online seemingly every time he was left alone with his screens.

From his particular fixation on Mr. Biden to his constant castigation of Democrats over all, Mr. Trump underlined the reality that his “unshakable bond” was with his Twitter megaphone. It was evident that his main interest was not where his hosts had gone to such lengths to direct it — on security and trade in Asia — but instead was on fighting with his perceived political enemies in Washington.