IRAN has vowed "harsh retaliation" for a US air strike near Baghdad's airport that killed Iran's top general and the architect of its interventions across the Middle East.

The killing of General Qasem Soleimani, the head of Iran's elite Quds Force, marks a major escalation in the stand-off between Washington and Iran, which has veered from one crisis to another since President Donald Trump withdrew from the 2015 nuclear deal and imposed crippling sanctions.

The United States urged its citizens to leave Iraq "immediately".

The State Department said the embassy in Baghdad, which was attacked by Iran-backed militiamen and other protesters earlier this week, is closed and all consular services have been suspended.

READ MORE: Raab calls for de-escalation after US strike on Iranian general

Around 5200 American troops are based in Iraq, where they mainly train Iraqi forces and help to combat militants of Daesh.

Iran's Supreme Leader Ayatollah Ali Khamenei warned that a "harsh retaliation is waiting" for the US after the air strike, calling Gen Soleimani the "international face of resistance".

Ayatollah Khamenei declared three days of public mourning for the general's death.

Iran also summoned the Swiss charges d'affaires, who represents US interests in Tehran, to protest over the killing.

The killing, and any forceful retaliation by Iran, could ignite a conflict that engulfs the whole region, endangering US troops in Iraq, Syria and beyond.

Over the last two decades Gen Soleimani had assembled a network of powerful and heavily armed allies stretching all the way to southern Lebanon, on Israel's doorstep.

The US Defence Department said it killed Soleimani because he "was actively developing plans to attack American diplomats and service members in Iraq and throughout the region".

It also accused Soleimani of approving the orchestrated violent protests at the US embassy in Baghdad earlier this week.

Iranian state television called Trump's order to kill Gen Soleimani "the biggest miscalculation by the US" since the Second World War.

"The people of the region will no longer allow Americans to stay," it said.

The airport strike also killed Abu Mahdi al-Muhandis, deputy commander of Iran-backed militias in Iraq known as the Popular Mobilisation Forces (PMF), and five others, including the PMF's airport protocol officer Mohammed Reda, Iraqi officials said.

Trump was holidaying on his estate in Palm Beach, Florida, but sent out a tweet of an American flag.

Former Middle East minister Alistair Burt has said the US launching an airstrike which killed Iran's most powerful military commander General Qasem Soleimani is "extremely serious".

Burt told BBC Radio 4's Today programme: "There is no agreement as to a base of the confrontations in the region, there is a completely different narrative put forward by the Iranians for what is happening in the region to that which is put forward by the United States and others – there is no meeting between to two."

He added that the airstrike could cause "a huge potential escalation" of the conflict, of which "the consequences are unknown".