Thousands of Iraqis have followed the coffin of Iranian military commander Qasem Soleimani, killed in a US air strike at Baghdad airport on Thursday.
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.
There were also reports of an explosion in Baghdad on Saturday evening.
It came as German military said in a letter the US and its allies had suspended training of Iraqi forces due to the increased threat they faced after the air strike.
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 heavily fortified Green Zone, where the US embassy is located.
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 said the bodies of Soleimani and four other Iranians killed in the air strike would 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.
Blasts hit Baghdad area
Several blasts shook the Baghdad area hours after the huge funeral procession.
On Saturday evening, a rocket fell inside Baghdad's heavily-fortified Green Zone near the US Embassy, another hit the nearby Jadriya neighbourhood and two more rockets were fired at the Balad air base north of the city, but no one was killed, the Iraqi military said in a statement.
There was no immediate claim of responsibility.
How has Iran responded to the assassination?
Iran's 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 earlier said 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?
The US says it has deployed an additional 3000 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 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.
Meanwhile, Iraq's PMF retracted their own report of a deadly new air strike on a convoy on Saturday, Reuters news agency 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 Islamic State 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.