In a speech to parliament on Tuesday, he also hit out at US counterpart Donald Trump saying he had shown the world that Washington was "not a good partner".
Rouhani's comments come with the nuclear deal under mounting pressure after Tehran carried out missile tests and Washington imposed new sanctions, with each accusing the other of violating the spirit of the agreement.
The US Treasury sanctioned six Iranian firms in late July for their role in the development of a ballistic missile programme after Tehran launched a rocket capable of putting a satellite into orbit.
Rouhani warned that Iran was ready to walk out of the 2015 deal, which saw the lifting of most international sanctions in return for curbs on its nuclear programme, if Washington persisted.
"Those who try to return to the language of threats and sanctions are prisoners of their past delusions," he said in the televised address.
"If they want to go back to that experience, definitely in a short time, not weeks or months, but in the scale of hours and days, we will return to our previous situation very much more stronger."
|An Iranian missile launch in July [Iranian Defence Ministry/AFP]|
In early August, Trump signed into law new sanctions on Iran, Russia, and North Korea that were passed by the US Congress.
The sanctions in that bill also target Iran's missile programmes as well as human rights abuses.
Washington imposed unilateral sanctions after saying Iran's ballistic missile tests violated a UN resolution that endorsed the nuclear deal and called upon Tehran not to undertake activities related to ballistic missiles capable of delivering nuclear weapons, including launches using such technology.
It stopped short of explicitly barring such activity.
Iran denies its missile development breaches the resolution, saying its missiles are not designed to carry nuclear weapons.
'Model of peace'
Rouhani said Iran preferred to stick with the nuclear deal, which he called "a model of victory for peace and diplomacy over war and unilateralism" but that this was not the "only option".
He said Trump had shown he was an unreliable partner not just for Iran but for US allies.
"In recent months, the world has witnessed that the US, in addition to its constant and repetitive breaking of its promises in the JCPOA [nuclear deal], has ignored several other global agreements and shown its allies that the US is neither a good partner nor a reliable negotiating party," he said.
He highlighted Trump's decisions to withdraw from the Paris climate agreement and international trade deals.
Iran's parliament on Sunday approved more than half a billion dollars in funding for the country's missile programme and foreign operations of the elite Islamic Revolutionary Guard Corps in response to the new US sanctions.
'Not a happy man'
Foad Azadi, a specialist in US-Iranian relations at the University of Tehran, told Al Jazeera the US sanctions had made it harder for Rouhani to counter those in the Iranian parliament who opposed the nuclear deal.
"We've had in previous years attempts to reduce tensions and resolve problems and basically each time the US was not interested," Azadi said.
"What the Trump administration is doing is trying to fulfil the promise that President Trump made during the [election] campaign, which is to tear apart the nuclear agreement.
"The actions of the US Congress and the signing of the new law is not making President Rouhani a happy man."