Donald Trump said Iran was in "serious discussions" following the build-up of US military forces nearby, as Iran's supreme leader Ayatollah Ali Khamenei warned any attack would spark a regional conflict.

The US president said he hoped negotiations would lead to something "acceptable". Iran's top security official Ali Larijani also said a framework for negotiations was progressing.

Trump has threatened to intervene in Iran over its nuclear ambitions and after its deadly crackdown on anti-government protests.

"The Americans should know that if they start a war, this time it will be a regional war," Khamenei was quoted as saying by the semi-official Tasnim news agency.

"[Trump] regularly says that he brought ships... The Iranian nation shall not be scared by these things."