Iran has promised vengeance after a United States air strike in Baghdad killed Qassem Soleimani, Tehran's most prominent military commander on Friday.
Soleimani, a 62-year-old general who headed the elite Quds Force, was regarded as the second most powerful figure in Iran after Supreme Leader Ayatollah Ali Khamenei.
The overnight attack, authorised by President Donald Trump, was a dramatic escalation in a "shadow war" in the Middle East between Iran and the US and its allies, principally Israel and Saudi Arabia.
Mr Trump defended his decision to launch the US airstrike, saying Mr Soleimani was responsible for killing and wounding "thousands" of Americans and many more in the region.
"He was directly and indirectly responsible for the death of millions of people, including the recent large number of PROTESTERS killed in Iran itself," Trump added.
"He should have been taken out many years ago".
....of PROTESTERS killed in Iran itself. While Iran will never be able to properly admit it, Soleimani was both hated and feared within the country. They are not nearly as saddened as the leaders will let the outside world believe. He should have been taken out many years ago!— Donald J. Trump (@realDonaldTrump) January 3, 2020
UN secretary-general Antonio Guterres stressed that "the world cannot afford another war in the Gulf," and urged leaders to "exercise maximum restraint" following the American action.
But Mr Khamenei said harsh revenge awaited the "criminals" who killed Soleimani and called for three days of national mourning.
Mr Soleimani's deputy, Brigadier General Esmail Ghaani, has been appointed to replace him.
As leader of the Quds Force, the foreign arm of the Revolutionary Guards, Mr Soleimani had a key role in fighting in Syria and Iraq.
Over two decades he was at the forefront of projecting the Islamic Republic's military influence across the Middle East.
President Hassan Rouhani said the assassination would stiffen Iranian resistance to the US, while the Revolutionary Guards said anti-US forces would exact revenge across the Muslim world.
Hundreds of Iranians marched toward Mr Khamenei's compound in Tehran to convey their condolences.
Israel has long seen Mr Soleimani as a major threat and Prime Minister Benjamin Netanyahu defended the US action. Israeli Army Radio said the military was on heightened alert.
Russia's Ministry of Defence called the killing a "short-sighted" step that would lead to escalations in the region.
Mr Soleimani had survived several assassination attempts by Western, Israeli and Arab agencies over the past two decades.
The Quds Force, tasked with operating beyond Iran's borders, shored up support for Syria's President Bashar al-Assad when he looked close to defeat in the civil war raging since 2011 and also helped militias defeat Islamic State in Iraq.