President Donald Trump threatened Iranian President Hassan Rouhani on Twitter late Sunday night after the Iranian leader issued a warning to the US president earlier in the day.

"To Iranian President Rouhani: NEVER, EVER THREATEN THE UNITED STATES AGAIN OR YOU WILL SUFFER CONSEQUENCES THE LIKES OF WHICH FEW THROUGHOUT HISTORY HAVE EVER SUFFERED BEFORE," Trump tweeted at Rouhani.

Trump in June had threatened sanctions on countries that purchased oil from Iran, which the Iranian leader dismissed.

President Donald Trump threatened Iranian President Hassan Rouhani on Twitter late Sunday night after the Iranian leader issued a warning to the US president earlier in the day.

"To Iranian President Rouhani: NEVER, EVER THREATEN THE UNITED STATES AGAIN OR YOU WILL SUFFER CONSEQUENCES THE LIKES OF WHICH FEW THROUGHOUT HISTORY HAVE EVER SUFFERED BEFORE," Trump tweeted at Rouhani.

"WE ARE NO LONGER A COUNTRY THAT WILL STAND FOR YOUR DEMENTED WORDS OF VIOLENCE & DEATH. BE CAUTIOUS!" the US President added.

Rouhani warned Trump earlier on Sunday not to pursue policies that were hostile towards Iran.

"Mr Trump, don't play with the lion's tail, this would only lead to regret," Rouhani told a group of diplomats, according to Reuters, citing the semi-official ISNA news agency.

Rouhani also dismised the idea that the US could stop Iran from exporting oil, according to Al Jazeera. The Trump administration in late June threatened sanctions on countries that purchase oil from Iran.

"Anyone who understands the rudiments of politics doesn’t say ‘we will stop Iran’s oil exports’...we have been the guarantor of the regional waterway’s security throughout history,” Rouhani said, Reuters reported.

But Rouhani also seemed to aim for peace. "America should know that peace with Iran is the mother of all peace, and war with Iran is the mother of all wars,” he said.