RIYADH, Saudi Arabia — As Secretary of State Mike Pompeo crisscrossed the Middle East this week to explain the U.S. military withdrawal from Syria, he repeated that he was “confident” and “optimistic” that he was nearing a deal with Turkey on a mutually agreeable exit plan.

But a pugnacious tweet from President Trump on Sunday night vowing to “devastate” the Turkish economy if Ankara attacks U.S.-backed Kurds revealed a much wider chasm between the two sides and prompted a new round of recriminations from Turkey.

The United States “will devastate Turkey economically if they hit Kurds,” Trump tweeted.

Hours later, Turkish Foreign Minister Mevlut Cavusoglu blasted Trump’s “threatening language.” He said his country was “not going to be scared or frightened off,” adding: “You will not get anywhere by threatening Turkey’s economy.”

The row marked the second time in a week that the White House has intervened in negotiations led by the State Department in a way that infuriated Turkey and caught U.S. diplomats flat-footed.

In trying to explain Trump’s tweets, Pompeo told reporters in Riyadh on Monday that he assumed that Trump meant the United States would levy sanctions on Turkey if it attacked the Kurds but that he did not know for certain.

“I assume he’s speaking about those kinds of things, but you would have to ask him,” said Pompeo, who noted that he had not talked to Trump about the tweet.

After Trump’s tweet, the Turkish lira lost about 0.84 percent of its value against the dollar.

This was not the first instance of mixed messaging from the White House and State Department on the delicate issue of leaving Syria.

Last week, Turkish President Recep Tayyip Erdogan erupted after national security adviser John Bolton made remarks conditioning the withdrawal of American troops from Syria on protection of Syrian Kurdish fighters who fought alongside U.S. forces against the Islamic State. Turkey’s government considers the Syrian Kurdish fighters, also known as the YPG, to be part of a terrorist movement and has vowed to attack them after the United States withdraws.

Bolton intended to refer specifically to America’s Kurdish proxy forces, but he struck a nerve by using imprecise language and appearing to dictate to Erdogan, U.S. and Turkish officials said.

The misstep angered James Jeffrey, the U.S. special envoy to the coalition against the Islamic State, who had been immersed in negotiations with the Turks when Bolton’s comment upended the talks, according to three people familiar with the negotiations.

Trump’s abrupt order to withdraw from Syria in December surprised U.S. allies and has left questions about the pace and scale of the pullout. Trump originally said U.S. troops were leaving “now,” but he has since said it would happen “slowly” after the United States ensured a lasting defeat of the Islamic State.

Later Monday, efforts appeared to be underway to de-escalate the standoff. The White House said Trump spoke to Erdogan on the phone about “ongoing cooperation in Syria as U.S. forces begin to withdraw” and the U.S. view that Turkey must not “mistreat the Kurds.” Press secretary Sarah Sanders said the chairman of the Joint Chiefs of Staff, Gen. Joseph F. Dunford Jr., will meet with his Turkish counterpart Tuesday to “continue consultations.”

Later Monday, Trump tweeted that he spoke to Erdogan “to advise where we stand on all matters including our last two weeks of success in fighting the remnants of ISIS, and 20 mile safe zone.”

He did not elaborate on what he meant by either reference. He took a very different tone than his threat Sunday.

“Also spoke about economic development between the U.S. & Turkey — great potential to substantially expand!” Trump wrote.

Pompeo said U.S. messaging over concerns about Turkish attacks on the Kurds has never changed.

“The administration has been very consistent with respect to our requirement that the Turks not go after the Kurds in ways that are inappropriate,” Pompeo said. “If they are terrorists, we’re all about taking down extremists wherever we find them. I think the president’s comments this morning are consistent with that.”

Trump’s Sunday and Monday tweets included a demand that Turkey create a “20 mile safe zone.” Pompeo said that U.S. and Turkish diplomats were negotiating such an arrangement this week but that nothing has been finalized. “We want to make sure that the folks who fought with us to take down the caliphate and ISIS have security and also that terrorists [in] Syria aren’t able to attack Turkey — those are our twin aims,” he told reporters after meeting with the leaders of Saudi Arabia in Riyadh.

“Both sides are trying to negotiate the width of a potential safe zone,” said Soner Cagaptay, a Turkey scholar at the Washington Institute for Near East Policy. “The idea is that Turkish troops and Ankara-backed forces would move into the rural areas in the safe zone, while the YPG would retain control of some of the Kurdish-majority cities. This would be a sharing agreement that might be acceptable to all sides, if the U.S. stands behind it.”

Other regional experts have questioned the concept of a buffer zone and who would patrol it. In addition, some of the border areas, including the Syrian town of Kobane, have predominately Kurdish populations, who would presumably resist being asked to withdraw.

Last year, just a month before he became the administration’s special envoy on Syria and the counter-Islamic State coalition in August, Jeffrey co-authored a paper calling for the establishment of a no-fly zone over northeastern Syria. The paper, written for the Washington Institute for Near East Policy, said such a policy would “meet the president’s troop withdrawal mandate,” satisfy Turkish concerns and keep forces loyal to Syrian President Bashar al-Assad from taking over the area. The Defense Department, which has long rejected a no-fly zone as too expensive, has been asked to provide options, and Jeffrey last week shared the idea with Syrian Kurdish fighters in northeastern Syria.

Cavusoglu expressed support for the 20-mile safe zone on Monday, saying it had long been a Turkish objective. “They bandied this idea after they saw Turkey’s determination,” he said. “We are not against it.”

With potential room for agreement, Cagaptay said a key factor will be avoiding diplomatic gaffes. “If there is one thing that makes the Turks’ blood boil, it is language that equates the Kurds and the YPG,” he said.

Fahim reported from Istanbul. Anne Gearan in Washington and Zeynep Karatas in Istanbul contributed to this report.