The following March, Mr. Obama was in Havana when bombs ripped through Brussels Airport and a subway station in the city, shifting attention away from his historic visit to Cuba and toward a renewed discussion about terrorism.

On Tuesday, it was Mr. Trump’s turn to be put on the spot by a grievous event.

In Israel on Tuesday, Mr. Trump began what were supposed to be remarks about his meeting with Mr. Abbas by pledging to support Britain and saying, “This wicked ideology must be obliterated, and I mean completely obliterated.”

His second event of the day — a speech at the Israel Museum about the Middle East peace process — also started with a return to the Manchester bombing and an acknowledgment that the subject of the rest of his trip would be the fight against terror.

“This trip is focused on that goal,” he said. “Bringing nations together around that goal.”

Mr. Trump began consultations with European leaders even before leaving the Middle East. In a telephone call with Prime Minister Theresa May of Britain, the president said he looked forward to discussing “the ways both countries can work with allies and partners around the world to defeat terrorism,” according to a White House summary of the call.

Even though the Manchester attack has the potential to overshadow the rest of Mr. Trump’s trip, it also echoed some of the themes the president had sought to emphasize during the first few days.