Thousands of Iraqis have followed the coffin of Iranian military commander Qasem Soleimani, killed in a US air strike at Baghdad airport on Friday.
Soleimani, viewed as a terrorist by the White House, was the architect of Iran's Middle East operations and Iran has vowed to take "severe revenge".
The funeral procession which began in Baghdad on Saturday marks the beginning of days of mourning for Soleimani.
His body is due to be returned to Iran for burial in his home town.
Iranian President Hassan Rouhani has promised members of the dead commander's family that Americans will "feel the impact" of their "criminal act... for years ahead".
The crowds in Baghdad were also there to mourn the death of Abu Mahdi al-Muhandis, an Iraqi who commanded the Iranian-backed Kataib Hezbollah group and effectively led the Popular Mobilisation Forces (PMF) - an umbrella of militias in Iraq dominated by groups aligned with Iran.
Both Baghdad's heavily fortified Green Zone, where the US embassy is located, and Balad air base north of the city came under rocket fire on Saturday but there were no immediate reports of casualties.
How did the Iraqi stage of the funeral proceed?
Mourners gathered in Baghdad in the early hours, waving Iraqi and militia flags and chanting "death to America".
The funeral began at the city's Al Muthana Airport, then moved to the gate of the Green Zone.
As the procession snaked though the streets, some mourners carried portraits of Soleimani while others held portraits of Iran's Supreme Leader, Ayatollah Ali Khamenei.
Later, the procession left for the Shia Muslim holy cities of Karbala and Najaf.
Reports say the bodies of Soleimani and four other Iranians killed in the air strike will be flown on Saturday evening to Iran, which has declared three days of mourning for the assassinated general. His funeral in Iran is to be held on Tuesday.
Some Iraqis, conversely, celebrated in Baghdad's streets at the news of Soleimani's death. He was accused of orchestrating violent crackdowns on peaceful pro-democracy protests there in recent months.
Iran's retaliation is certain, but when, where, how is not. For now, the priority is to cement Qasem Soleimani's status as a national hero, to ensure he remains powerful in death as in life.
Elaborate plans for his funeral have been expanded, a mix of carefully scripted ceremony with outpourings of grief filling the streets. It begins in Baghdad where he died, and where so much of his legacy lives.
From there his remains travel to Iran's holy city of Mashhad, to his hometown Kerman, and then to Tehran where the supreme leader will preside over final prayers - a rare honour, to send another signal. Ayatollah Khamenei has promoted his loyal officer to lieutenant general.
More important is to elevate his martyrdom, to draw in rivals who resented his status and Iranians who reviled his costly foreign adventures. Iranian leaders hope his killing will unite a nation as it stares at a far more uncertain future.
How has Iran responded to the assassination?
Its leaders have pledged to avenge the death of the man who led the Quds Force, an elite unit of the Iranian Revolutionary Guard Corps (IRGC).
Soleimani, 62, was widely seen as the second most powerful figure in Iran after Ayatollah Khamenei. The Quds Force reported directly to the ayatollah, and Soleimani was hailed as a heroic national figure.
Visiting Soleimani's family members at their house in Tehran, President Rouhani said: "The Americans really did not realise what grave error they have committed.
"Revenge for his blood will be exacted on that day when the filthy hands of America will be cut off forever from the region."
Ayatollah Khamenei said earlier that revenge would be "forceful" while a senior IRGC general, Gholamali Abuhamzeh, said 35 US targets had been identified in the region "as well as Tel Aviv" - the most populous city in Israel.
He also raised the prospect of attacks on US warships in the Gulf.
At a march in Tehran on Saturday, one demonstrator told Reuters: "[Soleimani] was a man who - unlike many of our officials - was an enemy for our enemies and treated our own people very well. Therefore he was very popular. So, the only thing we want of our statesmen and our supreme leader is... to take revenge."
Simmering US-Iranian hostilities had escalated rapidly last week after the US conducted air strikes in Iraq and Syria against Kataib Hezbollah, which the US blamed for an earlier rocket attack that killed an American civilian contractor. Pro-Iranian militia attacked the US embassy in Baghdad in response.
In a letter to the UN Security Council, responding to the strike on Soleimani, Iran's UN ambassador Majid Takht Ravanchi said that Iran reserved the right to self-defence under international law. Analysts said Iran could deploy cyber-attacks against the US, or attempt to strike US military targets or interests in the Middle East.
What measures is the US taking?
It says it has deployed an additional 3,000 troops to the Middle East to help respond to any backlash from the strike.
US citizens have been advised to leave Iraq immediately via any means possible, while the UK Foreign Office hardened its travel advice for Iran and Iraq.
Two previous US presidents, Barack Obama and George W Bush, had rejected a strike on the general as too risky.
Defending the operation to kill Soleimani, US President Donald Trump accused "the number one terrorist anywhere in the world" of "plotting imminent and sinister attacks on American diplomats and military personnel".
No details were given of the alleged planned attacks and a New York Times correspondent has quoted two unnamed US officials as telling her that evidence of such plotting was "razor thin".
Chinese Foreign Minister Wang Yi told his Iranian counterpart, Javad Zarif, that the US killing of Soleimani was an abuse of military power while Russian Foreign Minister Sergei Lavrov, who also phoned Mr Zarif, said the killing "grossly" violated the norms of international law.
1. I’ve had a chance to check in with sources, including two US officials who had intelligence briefings after the strike on Suleimani. Here is what I’ve learned. According to them, the evidence suggesting there was to be an imminent attack on American targets is “razor thin”.— Rukmini Callimachi (@rcallimachi) January 4, 2020
Meanwhile, Iraq's PMF retracted their own report of a deadly new air strike on a convoy on Saturday, Reuters reports.
How does Iraq fit into this?
Iran supports a variety of Shia militia groups in neighbouring Iraq. Soleimani had just arrived at Baghdad airport and was travelling in a convoy alongside officials from such militia when their cars were hit by several US missiles.
Iraq now finds itself in a difficult position as an ally both of Iran and of the US. Thousands of US troops remain in the country to assist in the broader struggle against the Sunni Muslim Islamic State (IS) group but Iraq's government insists the US has acted beyond the terms of this agreement.
Prime Minister Adel Abdul Mahdi labelled the missile strike as a "brazen violation of Iraq's sovereignty and a blatant attack on the nation's dignity" and Iraq's parliament announced it would hold an emergency meeting on Sunday.