WASHINGTON — As he confronted a series of international challenges from the Middle East to Asia last week, President Trump made certain that nothing was certain about his foreign policy. To the extent that a Trump Doctrine is emerging, it seems to be this: don’t get roped in by doctrine.

In a week in which he hosted foreign heads of state and launched a cruise missile strike against Syria’s government, Mr. Trump dispensed with his own dogma and forced other world leaders to re-examine their assumptions about how the United States will lead in this new era. He demonstrated a highly improvisational and situational approach that could inject a risky unpredictability into relations with potential antagonists, but he also opened the door to a more traditional American engagement with the world that eases allies’ fears.

As a private citizen and candidate, Mr. Trump spent years arguing that Syria’s civil war was not America’s problem, that Russia should be a friend, and that China was an “enemy” whose leaders should not be invited to dinner. As president, Mr. Trump, in the space of just days, involved America more directly in the Syrian morass than ever before, opened a new acrimonious rift with Russia, and invited China’s leader for a largely convivial, let’s-get-along dinner at his Florida estate.

In the process, Mr. Trump upended domestic politics as well. He rejected the nationalist wing of his own White House, led by Stephen K. Bannon, his chief strategist, who opposes entanglement in Middle East conflicts beyond fighting terrorism and favors punitive trade measures against Beijing. And Mr. Trump, by launching the strike on Russia’s ally Syria, undercut critics who have portrayed him as a Manchurian candidate doing the bidding of President Vladimir V. Putin after the Kremlin intervened in last year’s election on his behalf.