US 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 Mr 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.
Mr Trump's comments come in the context of a barrage of speeches and online communications meant to stir up unrest and pressure Iran to end its nuclear programme and its support of militant groups, according to US officials.
Iran has faced increased pressure and possible sanctions since Mr Trump's decision in May to withdraw the United States from a 2015 international agreement over Iran's nuclear programme.
In his message directed at Mr Rouhani, Mr 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 and death. Be cautious!"
On Sunday, Mr Rouhani told 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," state news agency IRNA quoted.
Mr 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 negotiations with the United States would be an "obvious mistake".
Mr Rouhani also scoffed at Mr Trump's threat to halt Iranian oil exports and said Iran had 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 Mr Trump's threats by saying Tehran would continue to resist its enemies.