"We will not be the first to violate the accord but they should definitely know that they will regret it if they violate it," Rouhani told a conference to mark National Nuclear Technology Day in Tehran.
"We are much more prepared than they think, and they will see that if they violate this accord, within a week, less than a week, they will see the result."
US President Donald Trump has threatened to walk away from the nuclear deal and reimpose sanctions by May 12 unless tough new restrictions are imposed on Iran's nuclear and missile programmes.
Rouhani dismissed the threat, saying: "It's been 15 months since this gentleman who came to power in America has been making claims and there have been many ups and downs in his remarks and his behaviour.
"(But) the foundations of the JCPOA (nuclear deal) have been so strong that during these 15 months of pressure... the structure has remained solid."
The other partners to the agreement -- Britain, France, Germany, China, Russia and the EU -- all agree that Iran has stuck by its commitments, as does the International Atomic Energy Association which is tasked with inspecting Iran's compliance.
"Even if one day (the US) can harm the JCPOA, we will be the winner in the public opinion of the world as the nation that stuck by its commitments," Rouhani said.
"If they withdraw, it would mean that they are not committed to their words."
Rouhani said the country's military and diplomatic powers were not aimed at intimidating its neighbours -- an apparent riposte to claims by Saudi Arabia that it is seeking to dominate the Middle East.
"Our path is clear. We are not thinking of threatening anyone. Our powers, even our military power is not for aggression against any country. Our relations with our neighbours will be friendly relations," Rouhani said.
He also took aim at his hardline opponents on the domestic front, who have criticised his efforts to reach out to the West.
"We need hard power. We need soft power... Some only look at one side of the coin," he said.