U.S. President Donald Trump told Iran it risked dire consequences "the like of which few throughout history have suffered before" if the Islamic Republic made more threats against the United States.
His words, spelled out in capital letters in a late night Twitter message, came hours after Iranian President Hassan Rouhani told Trump that hostile policies toward Tehran could lead to "the mother of all wars."
Despite the heightened rhetoric, both sides have reasons to want to avoid starting a conflict that could easily escalate.
Trump's comments come in the context of a barrage of speeches and online communications meant to foment unrest and pressure Iran to end its nuclear program and its support of militant groups, according to U.S. officials.
Iran has faced increased U.S. pressure and possible sanctions since Trump's decision in May to withdraw the United States from a 2015 international agreement over Iran's nuclear program.
In his message directed at Rouhani, Trump wrote: "Never, ever threaten the United States again or you will suffer consequences the likes of which few throughout history have ever suffered before. We are no longer a country that will stand for your demented words of violence & death. Be cautious!".
Earlier on Sunday, Rouhani had told a gathering of Iranian diplomats: "Mr Trump, don't play with the lion's tail, this would only lead to regret."
"America should know that peace with Iran is the mother of all peace, and war with Iran is the mother of all wars," said Rouhani, quoted by the state news agency IRNA.
Rouhani left open the possibility of peace between the two countries, at odds since the 1979 Islamic Revolution. But Iran's most powerful authority Supreme Leader Ayatollah Ali Khamenei said on Saturday negotiations with the United States would be an "obvious mistake".
Rouhani also scoffed at Trump's threat to halt Iranian oil exports and said Iran has a dominant position in the Gulf and the Strait of Hormuz, a major oil shipping waterway.
A senior commander of Iran's elite Revolutionary Guards reacted angrily to Trump's threats by saying Tehran would continue to resist its enemies, Iran's Students news Agency ISNA reported.
"We will never abandon our revolutionary beliefs ... we will resist pressure from enemies ... America wants nothing less than (to) destroy Iran ... (but) Trump cannot do a damn thing against Iran," Brigadier General Gholamhossein Gheybparvar said.
White House national security adviser John Bolton, who has in the past called for air strikes on Iran's nuclear facilities, said :"President Trump told me that if Iran does anything at all to the negative, they will pay a price like few countries have ever paid before", according to a White House statement.
Trump's threat to Iran came hours after a speech by U.S. Secretary of State Mike Pompeo who denounced Iran's clerical leadership as a "mafia" and promised unspecified backing for Iranians unhappy with their government.
Tehran reacted to Pompeo's speech as an interference in Tehran's affairs, the semi-official Tasnim news agency reported.
"Such policies will unite Iranians who will overcome plots against their country," Iranian Foreign Ministry spokesman Bahram Qasemi said.
Israeli Prime Minister Benjamin Netanyahu, who is bitterly opposed to Iran, praised Trump's "strong stance" on Tehran.
At the same time, Germany said threats of war were "never helpful".
There is limited appetite in Washington for a conflict with Iran, not least because of the difficulties the U.S. military faced in Iraq after its 2003 invasion but also because of the impact on the global economy if conflict raised oil prices.
Many ordinary Iranians are worried that the war of words might lead to a military confrontation but insiders in Tehran told Reuters that the U.S. administration would not drag the country into another quagmire in the Middle East.
With popular discontent over Iran’s faltering economy and sliding currency, and the prospect of tough new U.S. sanctions, Iran's leaders have called for unity.
Many ordinary Iranians are largely skeptical of the Trump administration's support for Iranian citizens because of the harsh U.S. sanctions on the country and a visa ban imposed on Iranians barring them from entering the United States.
While Washington prepares to reimpose economic sanctions on Tehran after pulling out of the nuclear deal, Iran's faction-ridden religious and political elites have closed ranks against Trump's hawkish approach to Tehran.
However, growing strains with the U.S. will eventually boost Rouhani's anti-Western hardline rivals who fear losing power if the nuclear deal, championed by Rouhani, ended the country’s political and economic isolation.
Rouhani's apparent threat earlier this month to disrupt oil shipments from neighboring countries came in reaction to efforts by Washington to force all countries to stop buying Iranian oil.
Washington initially planned to shut Iran out of global oil markets completely after Trump abandoned the deal that limited Iran's nuclear ambitions, demanding all other countries stop buying Iranian crude by November.
But the United States has somewhat eased its stance, saying it may grant sanction waivers to some allies that are particularly reliant on Iranian supplies.