While the president has said he wants to extricate America from foreign wars, he also ordered a carrier group into the Persian Gulf last month, and he has sometimes raised the possibility of military action.

Mr. Trump continues to rely for advice on leading hawks, the national security adviser, John Bolton, and Secretary of State Mike Pompeo, who on Thursday went beyond the tanker incidents to accuse Iran of several other attacks without offering proof.

At the same time, Mr. Trump has dangled the possibility of talks with the Iranians , and, however inept his international deal-making has previously proved to be, that approach is far preferable to the escalation apparently favored by some of his advisers. But he seems to be backing away from that course. “It is too soon to even think about making a deal,” he wrote in a tweet on Thursday.

Iran’s supreme leader, Ayatollah Ali Khamenei, was, if anything, more adamant about not even talking. When Prime Minister Shinzo Abe of Japan, who was visiting Tehran when the tankers were attacked, presented a message from Mr. Trump, the ayatollah, according to Iranian state media, responded, “I do not see Trump as worthy of any message exchange, and I do not have any reply for him, now or in future.”

It may be too soon for a deal, but it is not too soon to chart a course out of this turbulence.

Once American and allied intelligence agencies thoroughly investigate the tanker attacks, the data should be presented to the United Nations Security Council. It may be necessary for the United States and its partners to reflag and escort oil tankers in the Persian Gulf, as happened in 1987 and 1988, during the Iran-Iraq war.

Dialogue between the Trump administration and Iranian government would be wise, though Iran may prove unwilling to talk unless sanctions are eased and the United States rejoins the nuclear deal.

Meanwhile, attacks against civilian shipping in one of the world’s most vital international waterways, which sent crude oil prices up more than 3 percent on Thursday, have to stop. Every new provocation will make it harder to avoid a new regional cataclysm.