Speaking in an exclusive interview with CNN in New York, Rouhani said: "Exiting such an agreement would carry a high cost for the United States of America, and I do not believe Americans would be willing to pay such a high cost for something that will be useless for them."
Rouhani said such an action by the Trump administration "will yield no results for the United States but at the same time it will generally decrease and cut away and chip away at international trust placed in the Unites States of America."
It was mainly a procedural move, but it was significant, as re-imposing nuclear-related sanctions could lead to Iran ending its compliance with the deal and reverting back to rapid uranium enrichment -- something Iran has threatened to do if the US reneges on its end of this bargain.
The next major deadline comes in October, when Trump will decide whether to certify that Iran is complying with the agreement, known as the Joint Comprehensive Plan of Action (JCPOA). If he does not, Congress has 60 days to decide whether to reimpose sanctions waived under the deal.
Rouhani said Iran was ready to respond to the possibility of Trump walking away from the agreement.
"Given that Mr. Trump's actions and reactions and policies are somewhat unpredictable, we have thought long and hard about our reactions," he said.
He said any riposte from Iran would come "quite swiftly" and "probably within a week," adding that "if the US wants to increase the tensions it will see the reaction from Iran."
Rouhani, who was reelected by a popular vote to a second presidential term earlier this year, was a key architect of the 2015 nuclear agreement with the United States, the European Union and other partners.
The deal led to the lifting of most international sanctions against Iran in return for curbs on its nuclear program.
The agreement is expected to feature high on the agenda at this week's UN General Assembly in New York, which both Rouhani and Trump are attending.
On Thursday, Trump again attacked the agreement
, calling it "one of the worst deals I have ever seen."
"You'll see what I'm going to be doing very shortly in October," Trump told reporters aboard Air Force One. "But I will say this, the Iran deal is one of the worst deals I've ever seen, certainly at a minimum the spirit of the deal is just atrociously kept. But the Iran deal is not a fair deal to this country. It's a deal that should have never ever been made. And you'll see what we're doing in a couple of weeks."
Trump promised the US is "not going to stand for what they (Iran) are doing," arguing Iran has "violated so many different elements" of the deal.
He promised his upcoming action on the deal in October would be "very evident."
In the meantime, the International Atomic Energy Agency, the UN's nuclear watchdog, says Iran is complying with its commitments under the deal, including inspections.
Rouhani warned of the diplomatic precedent that would be set by pulling out of the Iran agreement, especially with regard to North Korea.
"I think what the Iranian experience shows is a good experience that can be replicated elsewhere and executed elsewhere," he said.
"But keep in mind please that if the United States wishes to withdraw from the JCPOA, why would the North Koreans waste their time in order to sit around the table of dialogue with the United States, because they would think perhaps after years of talks and a potential agreement the next US administration could step over or pull out of the agreement."
Syria and Myanmar
On the war in Syria, Rouhani stopped short of declaring an outright victory for the Syrian government, which Iran has supported on the ground, but described Tehran's intervention as a success.
"Our actions were successful and today we are witnessing the final stages of the defeat of ISIS" he said, before calling for eventual elections in Syria.
"The future of Syria will be determined by talks and ultimately the opposition must reach an agreement with the government and the will of people would be the ballot box should ultimately determine what happens," Rouhani told CNN.
CNN also asked Rouhani about Iran's position regarding the current crisis in Myanmar, where the government has been accused by the UN of ethnically cleansing Rohingya Muslims
. The Myanmar government has denied this, claiming security forces are carrying out counter attacks against "brutal acts of terrorism."
Rouhani said that Myanmar should be condemned and that aid should be forwarded to Bangladesh, where hundreds of thousands of Rohingya refugees have fled in recent weeks.
He also said he shared concerns that ISIS and al Qaeda fighters in Syria and Iraq could move across to Bangladesh and Myanmar to exploit the Rohingya crisis.
CNN also asked about foreign nationals and dual citizens detained in Iranian jails, including Nazanin Zaghari-Ratcliffe, a British-Iranian dual citizen who was arrested in 2016 and sentenced to five years' imprisonment, and the Iranian-American dual citizens Siamak Namazi and his father Baquer Namazi, who have been imprisoned since 2015 and 2016, respectively, and were each sentenced to 10 years.
A UN human rights panel has ruled that the Namazis are being held illegally and should be released, according to the American lawyer for the Namazis. The opinion of the United Nations Working Group on Arbitrary Detention has not been publicly released yet.
Rouhani said in an aside that he had his own views on the subject of detained foreigners and dual citizens, but that he was obliged to follow the Iranian constitution which had enshrined the separation of powers between the executive and the judiciary.
This story and its headline have been updated to reflect the accurate translation of Rouhani's remarks.