Mr Trump tweeted that Iran "will suffer consequences the likes of which few throughout history have ever suffered before" if it threatened the US.
Mr Rouhani earlier said that war with Iran would be "the mother of all wars".
In May, the US left a deal which curbed Iran's nuclear activities in return for the lifting of international sanctions.
Washington is now re-imposing the sanctions, despite objections from the UK, France, China, Russia and Germany, who all signed the 2015 agreement.
In a separate development on Sunday, US Secretary of State Mike Pompeo said the Iranian regime "resembles the mafia more than a government".
Addressing a group of Iranian Americans in California, Mr Pompeo denounced Mr Rouhani and Iranian Foreign Minister Javad Zarif, who negotiated the nuclear deal, as "merely polished front men for the ayatollahs' international con artistry".
Mr Pompeo said he wanted to try to stop countries importing Iranian oil by November as part of continued pressure on Tehran.
Why did the US withdraw?
In May, Mr Trump called the nuclear accord - or Joint Comprehensive Plan of Action (JCPOA) as it is formally known - a "horrible, one-sided deal that should have never, ever been made".
Mr Trump alleged that the deal did not restrict Iran's "destabilising activities" in the region enough, and could not detect or prevent any breaking of the terms of the deal.
Iran insists its nuclear programme is entirely peaceful, and its compliance with the deal has been verified by the International Atomic Energy Agency (IAEA), which has said Iran is honouring its commitments.