Tuesday's U.S. withdrawal from the accord was a "violation of morals", Rouhani said in remarks carried by state television.
"If the remaining five countries continue to abide by the agreement, Iran will remain in the deal despite the will of America," he said during a meeting with Sri Lanka's president.
U.S. President Donald Trump's pullout has upset Washington's European allies, cast uncertainty over global oil supplies and raised the risk of conflict in the Middle East.
It has also highlighted divisions among Iran's political elite.
Rouhani made similarly conciliatory comments on Tuesday, and on Saturday his foreign minister, Mohammad Javad Zarif, embarked on a tour of other signatory nations to the accord, state media reported, in a last-ditch effort to save it.
After arriving in Beijing on Sunday, Zarif said: "We hope that with this visit to China and other countries we will be able to construct a clear future design for the comprehensive (nuclear) agreement."
China's Foreign Minister Wang Yi said he believed Zarif's tour would "improve countries'... understanding of Iran's position." and help Tehran protect its "legitimate national interests".
The three European states have also recommitted to the agreement, but senior cleric Ayatollah Ahmad Khatami told worshippers at Tehran University on Friday that Europe was not to be trusted.
The head of the elite Revolutionary Guards also warned against relying on foreign powers to guarantee Iran's interests.
"America's exit aims to break the Iranian people's resistance, which is not new ...but today's problem is not U.S. sanctions, it's that some officials look towards outside rather than looking at domestic potentials," Guards commander General Mohammad Ali Jafari said, the state news agency IRNA reported.
On Wednesday, Jafari had cast doubt on European nations' ability to save the nuclear accord.
With the deal on shaky ground in the face of fierce opposition from hardliners at home, some analysts say the pragmatic Rouhani faces the prospect of serving out his second term as a lame duck leader.