The US and Iran stepped back from the brink of possible war as President Donald Trump indicated he would not respond militarily after no-one was harmed in Iran's missile strike on two Iraqi bases housing US troops.

Speaking from the White House, Trump seemed intent on de-escalating the crisis, which reached a new height after he authorised the targeted killing last week of General Qassem Soleimani, the head of Iran's elite Quds Force.

Iran retaliated overnight with its most direct assault on America since the 1979 seizing of the US embassy in Tehran, firing more than a dozen missiles from its territory at the US installations.

Trump credited an early warning system "that worked very well" for the fact that no Americans or Iraqis were killed.

He added that Americans should be "extremely grateful and happy" with the outcome.

READ MORE: Expert: Bomb or missile likely cause of Iran plane crash

Trump, facing one of the greatest tests of his presidency, said Iran appeared to be "standing down" and said the US response would be to put in place new economic sanctions "until Iran changes its behaviour".

The strikes had pushed Tehran and Washington perilously close to all-out conflict and put the world's attention on Trump as he weighed whether to respond with more military force.

The Republican president delivered his remarks surrounded by his national security advisers in the foyer of the White House.

It came after a late-night tweet in which he insisted "All is well!" after the strikes.

For days, Iran had promised to respond forcefully to Gen Soleimani's killing, but its limited strike on two bases - one in the northern Iraqi city in Irbil and the other at Ain al-Asad in western Iraq - appeared to signal that it was also uninterested in a wider clash with the US.

Foreign minister Mohammad Javad Zarif tweeted that the country had "concluded proportionate measures in self-defence".

Trump, who is facing re-election in November, campaigned for president on a promise to keep the United States from engaging in "endless war".

Speaking on Wednesday, he said the United States is "ready to embrace peace with all who seek it".

READ MORE: Iran: 176 people killed in Ukraine Boeing plane crash near Tehran

Trump opened his remarks by reiterating his promise that "Iran will never be allowed to have a nuclear weapon", even as the country announced in the wake of Gen Soleimani's killing that it would no longer comply with any of the 2015 nuclear deal's limits on enrichment that had been put in place to prevent it from building a nuclear device.

But he seized on the – at least temporary – moment of calm to call for new nuclear negotiations to replace the 2015 deal from which he withdrew the US, objecting that it did not limit Iran's ballistic missile programmes or constrain its regional proxy campaigns like those led by Gen Soleimani.

The president spoke directly to Iran, saying: "We want you to have a future and a great future."

Trump also announced he would ask Nato to become "much more involved in the Middle East process".

While he has frequently criticised Nato as obsolete and has encouraged participants to increase their military spending, Trump has sought to have the military alliance refocus its efforts on modern threats.

Turkish President Recep Tayyip Erdogan and Russian President Vladimir Putin in a joint statement had warned that the further use of force "would lead to a new cycle of instability and would eventually damage everyone's interests".

However, in the hours before the missile strikes, Trump warned: "If Iran does anything that they shouldn't be doing, they're going to be suffering the consequences, and very strongly."

And Iran's Supreme Leader Ayatollah Ali Khamenei, speaking on Wednesday, said the strike was not necessarily the totality of Iran's response.

"Last night they received a slap," Ayatollah Khamenei said.

"These military actions are not sufficient (for revenge). What is important is that the corrupt presence of America in this region comes to an end."

Gen Soleimani's death last week in an American drone strike in Baghdad prompted angry calls for vengeance and drew massive crowds of Iranians to the streets to mourn him.

The Iranians fired a total of 15 missiles in the latest strikes, two US officials said.

Ten hit the Ain al-Asad air base in Iraq's western Anbar province and one targeted a base in Irbil in Iraq's semi-autonomous Kurdish region while four failed, said the officials.