For a year, Mr. Zarif and President Hassan Rouhani seemed to hold Iran’s hard-line factions at bay. They asserted that it was better to stay within the limits of the nuclear accord — even if the United States was in violation of its own commitments to suspend sanctions — than to incite a crisis.

The Europeans appeared to side with Iran, declaring publicly that Mr. Trump was making a huge mistake by abandoning an agreement that, at least for the next dozen years or so, would keep Iran from producing the fuel for a nuclear weapon.

In an interview in New York in late April, Mr. Zarif said that he was fighting a back-channel bureaucratic struggle in Iran to preserve the agreement “every day.” He ended with a suggestion for the Trump administration: Rather than look for new ways to maximize pain, try “showing some respect.”

Last month, it became clear that Mr. Rouhani and Mr. Zarif, often denounced at home for being too cozy with the United States, were losing that internal argument.

Under pressure to explain why a deal that he promised would help lift economic sanctions had only resulted in even harsher ones, Mr. Rouhani announced that Iran would begin to edge out of the nuclear restrictions, loosening different elements of them every 60 days unless the Europeans found a way to make up for the American-imposed penalties.

While a slow move rather than a drastic one, it also signaled a new moment of confrontation between Iran and the West and a moment for the Revolutionary Guards — designated as a terrorist organization by Mr. Pompeo over the objections of the Pentagon — to flex its muscles.

“Does the Iranian government want this sort of stuff now? No,” said Sir John Jenkins, a former British ambassador to Saudi Arabia with deep experience in the region. But the Revolutionary Guards, which profits greatly from black-market trade that thrives in times of sanctions and sees a chance to embarrass Mr. Rouhani, “might have an incentive to keep people rattled.”