The United States killed Iranian Major-General Qassem Soleimani, head of the elite Quds Force and architect of Iran's spreading military influence in the Middle East, in an air strike on Friday at Baghdad airport, the Pentagon and Iran said.
Top Iraqi militia commander Abu Mahdi al-Muhandis, an adviser to Soleimani, was also killed in the attack that was authorised by U.S. 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.
Iran's Supreme Leader Ayatollah Ali Khamenei vowed harsh revenge.
Iran has been locked in a long conflict with the United States that escalated sharply last week with an attack on the U.S. embassy in Iraq by pro-Iranian militiamen following a US air raid on the Kataib Hezbollah militia, founded by Muhandis.
"At the direction of the president, the U.S. military has taken decisive defensive action to protect U.S. personnel abroad by killing Qassem Soleimani," the Pentagon said in a statement.
"This strike was aimed at deterring future Iranian attack plans," it added.
U.S. 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.
Pictures showed burning debris on a road near the airport.
Oil prices were up nearly $3 on the news.
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 while Iran's Revolutionary Guards said anti-U.S. forces would exact revenge across the Muslim world.
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.
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.
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.
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.
Iraqi Shi’ite cleric Moqtada al-Sadr, who portrays himself a nationalist rejecting both Iranian and US influence, ordered his followers to be ready to defend Iraq and urged all sides to behave wisely.
The Syrian government of President Bashar al-Assad condemned was it called criminal US aggression.
FORCEFUL RESPONSE LIKELY ::
The slain commander's Quds Force, along with its stable of paramilitary proxies from Lebanon's Hezbollah to the PMF in Iraq - battle-hardened militias armed with missiles - has ample means to launch a multi-pronged response.
In September, U.S. officials blamed Iran for a devastating missile and drone attack on oil installations of Saudi Aramco, the Saudi state energy giant and world's largest oil exporter. The Trump administration did not respond, beyond heated rhetoric and threats.
Iran, for its part, has absorbed scores of air strikes and missile attacks, mainly carried out by Israel against its fighters and proxies in Syria and Iraq.
But analysts say Iran is likely to respond forcefully to the targeting of Soleimani, who it has built into a legend as its influence has spread across the region in the wake of the US-led invasion of Iraq in 2003 and subsequent occupation
Soleimani, who has led the foreign arm of the Revolutionary Guards and has had a key role in fighting in Syria and Iraq, acquired celebrity status at home and abroad.
He survived several assassination attempts against him by Western, Israeli and Arab agencies over the past two decades.
His Quds Force, tasked with carrying out operations beyond Iran's borders, shored up support for Syria's Assad when he looked close to defeat in the civil war raging since 2011 and also helped militiamen defeat Islamic State in Iraq.
He became head of the Quds Force in 1998, a position in which he kept a low profile for years while he strengthened Iran's ties with Hezbollah in Lebanon, Syria's government and Shi’ite militia groups in Iraq.
Muhandis, who was killed with Soleimani, oversaw Iraq’s PMF, a grouping of paramilitary groups mostly consisting of Iran-backed Shi’ite militias that was formally integrated into Iraqi armed forces.
His Kataib Hezbollah militia, which received battlefield training from Lebanon’s Hezbollah, has long targeted U.S. forces and was one of the earliest groups to send fighters to Syria to support Assad.
In 2009, Washington declared Kataib Hezbollah a foreign terrorist organization, saying it threatened stability in Iraq and declared Muhandis a terrorist. In 2007, a Kuwaiti court sentenced him to death in absentia for his involvement in the 1983 US and French embassy bombings in Kuwait.
Iran's ambassador to Iraq told state television that Soleimani's body would be sent to Iran.