Iranian President Hassan Rouhani said on Sunday that if the United States quits the nuclear deal between Tehran and world powers then Washington would regret it "like never before."
US President Donald Trump has threatened to withdraw from the agreement when it comes up for renewal on May 12, demanding his country's European allies "fix the terrible flaws" or he will re-impose sanctions.
"If the United States leaves the nuclear agreement, you will soon see that they will regret it like never before in history," reformist Rouhani said in a televised speech in northwestern Iran.
"Trump must know that our people are united, the Zionist regime (Israel) must know that our people are united," Rouhani said.
"Today all (Iran's) political factions, whether they be from the right, the left, the conservatives, reformers and moderates are united," he added.
The nuclear deal was struck in 2015 between Iran and Britain, China, France, Germany, Russia and the United States, then led by Barack Obama.
Under the pact, sanctions were eased in return for a commitment not to pursue a nuclear bomb, but Iran says it is not reaping the rewards despite complying with the deal.
Trump has consistently complained about the agreement, citing perceived flaws including "sunset" provisions lifting some nuclear restrictions from 2025.
In an attempt to salvage the deal, French President Emmanuel Macron has recently pushed to extend its scope to address this issue, as well as the absence of any limits on Iran's conventional missile capabilities and Tehran's role in the region.
Iran's support for Syrian President Bashar al-Assad, via the Lebanese armed group Hezbollah in Syria's civil war, and its backing for Shiite Huthi rebels in Yemen have added to frictions between Tehran and Western powers.
Rouhani vehemently reiterated his country's opposition to curtailing its non-nuclear missile capabilities, in his speech on Sunday.
Tehran "will build as many missiles and weapons as needed" for its defence, he said.
"We are honouring our commitment, but we are telling the whole world we will not negotiate with anyone about our weapons and our defence."
Iran's president also said that while he is open to discussing the country's regional role, he would not abandon what he described as its fight "against terrorism."
"We want to talk to the world so that our region is safe" but "we will not allow you to create a new Daesh" he said, using an Arabic term for the Islamic State group.
While Rouhani did not elaborate on this point, Iran's ally the Syrian government has consistently referred to all armed opponents as "terrorists" and accused the West of facilitating terrorism.
Iran has always denied it sought a nuclear weapon, insisting its atomic programme was for civilian purposes.
Rouhani did not specify how Iran would react if the US pulls out of the 2015 deal.
But he said he had given "the necessary orders," notably to Iran's Atomic Energy Organisation, in anticipation of Trump's decision.
As the May 12 US decision point nears, Iranian leaders have shuffled between placatory and hawkish comments, although the hardliners have taken a uncompromising stance.
On Thursday Ali Akbar Velayati, the foreign policy adviser to Iran's supreme leader Ayatollah Ali Khamenei, warned Tehran would quit the nuclear deal if the United States withdraws.