Iran has stepped up its war of words with the US, with an influential adviser to the supreme leader threatening the Trump administration with "dark days to come" in case of a military attack on his country.

In an exclusive interview with Al Jazeera, Ali Akbar Velayati, foreign affairs adviser to Ayatollah Ali Khamenei, said: "Washington does not dare carry out its military threats against Iran."

"The Americans know very well that Iran and its allies in the region would retaliate very hard. That will make America face dark days to come," he said.

In the past week, the US has imposed new sanctions on Iran over a missile test.

Velayati said Iran's policies in the Middle East would not change, "therefore [President Donald] Trump and the American administration must get their stuff together and leave this region completely because the people of this region feel alienated by their policies".

Velayati said the US effort to make Iran stop its missile programme with military threats amounted to "worthless fantasies".

"Without the slightest doubt, I can guarantee you that we will continue to develop our military programmes, and especially our defence missile programme, no matter what and at any cost," he said.

"We do not have any worry about the US threats because America for the last 38 years after the Islamic revolution has not been able to do anything."

Relations between the US and Iran have deteriorated since Trump took office on January 20, promising a more aggressive line on what he views as Iranian belligerence towards US interests and allies.

Last week Michael Flynn, US national security adviser, accused Iran of violating a UN Security Council resolution which calls on Iran not to test missiles capable of delivering a nuclear weapon.

'Playing with fire'

Iran has confirmed it tested a ballistic missile, but denied it was a breach of a 2015 nuclear deal with world powers or UN resolutions.

Trump said Iran was "playing with fire" after the country dismissed his warnings over the missile test as unfounded and provocative.

In a post on Twitter, Trump said his administration would not be as "kind" to Iran as the government of his predecessor, Barack Obama.

"Iran is playing with fire - they don't appreciate how 'kind' President Obama was to them. Not me!" Trump said.

READ MORE: US slaps new sanctions on Iran over missile test

Asked by a reporter if military action was a possibility, Trump said: "Nothing is off the table."

The US later imposed sanctions on 13 Iranians and 12 companies.

Lawrence Korb, a former US assistant defence secretary, says Trump's team would probably prevent him from making irrational moves in the Middle East.

"There are people like General [James] Mattis, who has a 40-year career in the military and General [John F] Kelly, who runs our department of homeland security ... who we have to hope will prevent the president from doing things that his instincts lead him to," Korb told Al Jazeera from Washington DC.