Iran has vowed harsh revenge after the United States killed Iranian Major-General Qassem Soleimani in an air strike at Baghdad airport.
Soleimani was head of the elite Quds Force and architect of Iran's spreading military influence in the Middle East.
Top Iraqi militia commander Abu Mahdi al-Muhandis, an adviser to Soleimani, was also killed in the attack that was authorised by US President Donald Trump.
Soleimani's killing marks a dramatic escalation in the regional "shadow war" between Iran and the United States and its allies, principally Israel and Saudi Arabia, which could quickly ratchet up tit-for-tat attacks.
A Iran's Revolutionary Guards (IRG) spokesperson told Iranian state television IRG and anti-US forces across the Muslim world will avenge the assassination of Quds Force chief Qassem Soleimani.
"The Revolutionary Guards, the wise Iranian nation and the resistance front across the geographical expanse of the Muslim nation will avenge the blood of this martyr (Soleimani)," IRG spokesperson Ramezan Sharif told the broadcaster.
"The joy of the Zionists and Americans will in no time turn into mourning."
Iran often refers to regional countries and forces opposed to Israel and the United States as a "resistance front".
Iran-backed Iraqi militia commander Qais al-Khazali ordered his fighters to be on high alert for an upcoming battle, and said that US military presence in Iraq would end soon.
"All fighters should be on high alert for upcoming battle and great victory. The price for the blood for the martyred commander Abu Mahdi al-Muhandis is the complete end to American military presence in Iraq," local TV channel al-Ahd, which is close to his Asaib Ahl al-Haq militia quoted him as saying.
Iraqi Shi'ite cleric Moqtada al-Sadr, who portrays himself a nationalist rejecting both Iranian and US influence, also ordered his followers to be ready to defend Iraq and urged all sides to behave wisely.
The United States embassy in Baghdad urged all citizens to depart Iraq immediately, hours after the air strike.
"Due to heightened tensions in Iraq and the region, the US Embassy urges American citizens to heed the January 2020 Travel Advisory and depart Iraq immediately. US citizens should depart via airline while possible, and failing that, to other countries via land," it said in a statement.
Iran's Supreme Leader Ayatollah Ali Khamenei vowed harsh revenge.
Khamenei said harsh revenge awaited the "criminals" who killed Soleimani and his death, though bitter, would double the motivation of the resistance against the United States and Israel.
"All enemies should know that the jihad of resistance will continue with a doubled motivation, and a definite victory awaits the fighters in the holy war," Khamenei said in a statement carried by state television, in which he called for three days of national mourning.
But it could be difficult for Iran to plan and carry out the kind of sophisticated attacks that Soleimani was accused of masterminding during his over 20 years of projecting the Islamic Republic's military influence across the Middle East.
State television presenters wore black and broadcast footage of Soleimani peering through binoculars across a desert and greeting a soldier, and of Muhandis speaking to followers.
President Hassan Rouhani said the assassination would make Iran more decisive in its resistance to the United States.
Iraqi Prime Minister Adel Abdul Mahdi condemned the "assassination" of Soleimani and Muhandis.
In a statement, he said the air strike on Baghdad airport is an act of aggression on Iraq and breach of its sovereignty that will lead to war in Iraq, the region, and the world.
The strike also violated the conditions of US military presence in Iraq and should be met with legislation that safeguards Iraq's security and sovereignty, he said.
He called on parliament to convene in an extraordinary session.
Iran has been locked in a long conflict with the United States that escalated sharply last week with an attack on the US embassy in Iraq by pro-Iranian militiamen following a US air raid on the Kataib Hezbollah militia, founded by Muhandis.
Iraqi paramilitary groups said three rockets hit Baghdad International Airport, killing five members of Iraqi paramilitary groups and two "guests".
The rockets landed near the air cargo terminal, burning two vehicles, killing and injuring several people. Pictures showed burning debris on a road near the airport.
US officials, speaking on the condition of anonymity, said that Soleimani had been killed in a drone strike. Iran's Revolutionary Guards said he was killed in an attack by American helicopters.
In a statement, the Pentagon said: "At the direction of the president, the US military has taken decisive defensive action to protect US personnel abroad by killing Qassem Soleimani.
"This strike was aimed at deterring future Iranian attack plans," it added.
Local militia commander Abu Muntathar al-Hussaini told Reuters the two leaders were in a vehicle struck by two missiles as they were on their way out of the airport from its arrivals hall. The second vehicle, carrying bodyguards from the PMF, was hit by one rocket, he said.
"The American criminals had detailed information on the convoy's movements," Hussaini said.
Ahmed al-Assadi, a spokesman for Iraq's Popular Mobilisation Forces (PMF), the umbrella grouping of Iran-backed militias, blamed the United States and Israel for the killing of Soleimani and Muhandis.
Reaction to the killing
Trump, who is facing impeachment charges, made no immediate comment but posted a picture of the US flag on Twitter.
In Israel, the government of Prime Minister Benjamin Netanyahu - which has long regarded Soleimani as a major threat - gave no immediate response to his death but Israel Army Radio said the military had gone on heightened alert.
Lebanon's Hezbollah leader Sayyed Hassan Nasrallah said his powerful Shi'ite militia group would continue the path of Soleimani after his death in a US air strike, broadcaster Al Manar reported.
Nasrallah said the United States would not be able to achieve its goals with this "big crime" and just punishment was the responsibility of all fighters, Al Manar reported.
The Syrian government of President Bashar al-Assad condemned what it called criminal US aggression.
Russia's Foreign Ministry said that the killing of Soleimani would increase tensions in the Middle East, RIA news agency reported.
France's embassy in Tehran urged its citizens in Iran to stay away from public gatherings after news of Soleimani's death.
"Three days of mourning have been declared after the death of General Soleimani. In this context, we recommend French citizens to stay away from any gatherings and to behave with prudence and discretion and abstain from taking pictures in public spaces," it said in a statement on Twitter.