Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Iranian President Hassan Rouhani on Sunday cautioned President Donald Trump about pursuing hostile policies against Tehran, saying "America should know ... war with Iran is the mother of all wars," the state news agency IRNA reported.

Iran faces increased U.S. pressure and looming sanctions after Trump's decision to withdraw the United States from a 2015 international deal over Iran's nuclear program.

Addressing a gathering of Iranian diplomats, Rouhani said: "Mr Trump, don't play with the lion's tail, this would only lead to regret," IRNA reported.

"America should know that peace with Iran is the mother of all peace, and war with Iran is the mother of all wars," Rouhani said, leaving open the possibility of peace between the two countries which have been at odds since the 1979 Islamic Revolution.

"You are not in a position to incite the Iranian nation against Iran's security and interests," Rouhani said, in an apparent reference to reported efforts by Washington to destabilize Iran's Islamic government.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Rouhani scoffed at Trump's threat to halt Iranian oil exports and said Iran has a dominant position in the Gulf and the Strait of Hormuz, a major oil shipping waterway.

"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, cited by the semi-official ISNA news agency.

Trump countered late Sunday with a threat of his own. In a tweet, largely in all caps, the president said further threats from Iran would bring "CONSEQUENCES THE LIKES OF WHICH FEW THROUGHOUT HISTORY HAVE EVER SUFFERED BEFORE. WE ARE NO LONGER A COUNTRY THAT WILL STAND FOR YOUR DEMENTED WORDS OF VIOLENCE & DEATH. BE CAUTIOUS!"

Iran's Supreme Leader Ayatollah Ali Khamenei on Saturday backed Rouhani's suggestion that Iran may block Gulf oil exports if its own exports are halted.

Rouhani's apparent threat earlier this month to disrupt oil shipments from neighboring countries came in reaction to efforts by Washington to force all countries to stop buying Iranian oil.

Iranian officials have in the past threatened to block the Strait of Hormuz in retaliation for any hostile U.S. action.

Separately, a top Iranian military commander warned that the Trump government might be preparing to invade Iran.

"The enemy's behavior is unpredictable," military chief of staff General Mohammad Baqeri said, the semi-official Tasnim news agency reported.

"Although the current American government does not seem to speak of a military threat, according to precise information it has been trying to persuade the U.S. military to launch a military invasion (of Iran)," Baqeri said.

Iran's oil exports could fall by as much as two-thirds by the end of the year because of new U.S. sanctions, putting oil markets under huge strain amid supply outages elsewhere.

Washington initially planned to totally shut Iran out of global oil markets after Trump abandoned the deal that limited Iran's nuclear ambitions, demanding all other countries to stop buying its crude by November.

But it has somewhat eased its stance since, saying that it may grant sanction waivers to some allies that are particularly reliant on Iranian supplies.