Thousands of militiamen and other mourners chanting “America is the Great Satan” marched in a funeral procession in Baghdad for Iran’s top general after he was killed in a US air strike, as the region braced for the Islamic Republic to fulfil its vows of revenge.

General Qassem Soleimani, the head of Iran’s elite Quds Force and mastermind of its regional security strategy, was killed early Friday near Baghdad international airport along with senior Iraqi militants in an air strike ordered by US President Donald Trump.

The attack has caused regional tensions to soar and tested the US alliance with Iraq.

Iran has vowed harsh retaliation, raising fears of an all-out war, but it is unclear how or when it might respond.

Any retaliation was likely to come after three days of mourning declared by Supreme Leader Ayatollah Ali Khamenei.

All eyes were on Iraq, where America and Iran have competed for influence since the 2003 US-led invasion.

Mr Trump says he ordered the strike, a high-risk decision that was made without consulting Congress or US allies, to prevent a conflict.

US officials say Soleimani was plotting a series of attacks that endangered American troops and officials, without providing evidence.

The US-led coalition has scaled back operations and boosted “security and defensive measures” at bases hosting coalition forces in Iraq, a coalition official said.

Qassem Soleimani protesters
In Tehran, Iran, protesters demonstrated against the killing (Ebrahim Noroozi/AP)

The US has meanwhile dispatched another 3,000 troops to neighbouring Kuwait, the latest in a series of deployments in recent months as the standoff with Iran has worsened.

Soleimani was the architect of Iran’s regional policy of mobilising militias across Iraq, Syria and Lebanon, including in the war against the Islamic State group.

He was also blamed for attacks on US troops and American allies going back decades.

In Baghdad, thousands of mourners, mostly men in black military fatigues, carried Iraqi flags and the flags of Iran-backed militias that are fiercely loyal to Soleimani at Saturday’s ceremony.

They were also mourning Abu Mahdi al-Muhandis, a senior Iraqi militia commander who was killed in the same strike.

The mourners, many of them in tears, chanted “No, No, America,” and “Death to America, death to Israel”.

Qassem Soleimani funeral
Mourners burn a US flag during the funeral (Nasser Nasser/AP)

Mohammed Fadl, a mourner dressed in black, said the funeral is an expression of loyalty to the men.

“It is a painful strike, but it will not shake us,” he said.

Helicopters hovered over the procession, which was attended by prime minister Adel Abdul-Mahdi and leaders of Iran-backed militias.

The procession later made its way to the Shiite holy city of Karbala, where the mourners raised red flags associated with unjust bloodshed and revenge.

The militants will be buried in Najaf, while Soleimani’s remains will be taken to Iran.

More funeral services will be held for Soleimani in Iran on Sunday and Monday, before his body is laid to rest in his hometown of Kerman.

Qassem Soleimani protest
Many protesters were emotional during a demonstration against the killing of Soleimani in Tehran (Ebrahim Noroozi/AP)

The gates to Baghdad’s Green Zone, which houses government offices and foreign embassies, including the US embassy, were closed Saturday.

Iraq’s government, which is closely allied with Iran, condemned the air strike that killed Soleimani, calling it an attack on its national sovereignty.

Parliament is meeting for an emergency session Sunday, and the government has come under mounting pressure to expel the 5,200 American troops based in the country, who are there to help prevent a resurgence of the Islamic State group.

Hadi al-Amiri, who heads a large parliamentary bloc and is expected to replace al-Muhandis as deputy commander of the Popular Mobilisation Forces, an umbrella group of mostly Iran-backed militias, was among those paying their final respects in Baghdad.

“Rest assured,” he said before al-Muhandis’ coffin in a video circulated on social media. “The price of your pure blood will be the exit of US forces from Iraq forever.”

Protesters chant slogans during a demonstration in Tehran
Protesters chant slogans during a demonstration in Tehran (Ebrahim Noroozi/AP)

The US has ordered all citizens to leave Iraq and temporarily closed its embassy in Baghdad, where Iran-backed militiamen and their supporters staged two days of violent protests earlier this week in which they breached the compound.

No-one was hurt in the embassy protests, which came in response to US air strikes that killed 25 Iran-backed militiamen in Iraq and Syria.

The US blamed the militia for a rocket attack that killed a US contractor in northern Iraq.

Tensions between the US and Iran have steadily intensified since Mr Trump’s decision to withdraw from the 2015 nuclear deal and restore crippling sanctions, which have devastated Iran’s economy and contributed to recent protests there in which hundreds were reportedly killed.

The administration’s “maximum pressure” campaign has led Iran to openly abandon commitments under the deal.

The US has also blamed Iran for a wave of increasingly provocative attacks in the region, including the sabotage of oil tankers in the Persian Gulf and an attack on Saudi Arabia’s oil infrastructure in September that temporarily halved its production.

Protesters demonstrate in Tehran
Protesters demonstrate in Tehran (Ebrahim Noroozi/AP)

Iran denied involvement in those attacks, but admitted to shooting down a US surveillance drone in June, saying it had strayed into its airspace.

Billboards and images of Soleimani, who was widely seen as a national icon and a hero of the so-called Axis of Resistance against Western hegemony, appeared on major streets in Iran Saturday with the warning from the supreme leader that “harsh revenge” awaits the US.

Iranian President Hassan Rouhani visited Soleimani’s home in Tehran to express his condolences.

“The Americans did not realise what a great mistake they made,” Mr Rouhani said. “They will see the effects of this criminal act, not only today but for years to come.”

On the streets of Tehran, many mourned Soleimani.

“I don’t think there will be a war, but we must get his revenge,” said Hojjat Sanieefar. America “can’t hit and run any more,” he added.

Another man, who only identified himself as Amir, said: “If there is a war, I am 100% sure it will not be to our betterment. The situation will certainly get worse.”

In an apparent effort to defuse tensions, Qatar’s foreign minister, Sheikh Mohammed bin Abdulrahman Al Thani, made an unplanned trip to Iran where he met Mr Rouhani and other senior officials.

Qatar, which has often served as a regional mediator, hosts American forces at the Al-Udeid Air Base and shares a massive offshore oil and gas field with Iran.

Secretary of State Mike Pompeo meanwhile said he had spoken to Iraqi President Barham Salih, Turkish foreign minister Mevlut Cavusoglu and Abu Dhabi Crown Prince Sheikh Mohammed bin Zayed Al Nahyan, of the United Arab Emirates.

“I reaffirmed that the U.S. remains committed to de-escalation,” Mr Pompeo tweeted.

A Saudi official had earlier confirmed that the US did not co-ordinate with Saudi Arabia before carrying out the strike that killed Soleimani.

In a sign of his regional reach, supporters in Lebanon hung billboards commemorating Soleimani in Beirut’s southern suburbs and in southern Lebanon along the disputed border with Israel, according to the state-run National News Agency.

Both are strongholds of the Iran-backed Hezbollah militant group, whose leader, Hassan Nasrallah, has close ties to Soleimani.

A portrait of Nasrallah could be seen in Soleimani’s home when mourners paid tribute there.

Palestinian factions in the Gaza Strip, including the territory’s Hamas rulers, opened a mourning site for the general and dozens gathered to burn American and Israeli flags.

Iran has long provided aid to the armed wing of Hamas and to the smaller Islamic Jihad militant group.

Ismail Radwan, a senior Hamas official, said the killing of Soleimani was “a loss for Palestine and the resistance”.