Supporters of Iran-backed Iraqi paramilitary groups began to withdraw from the US embassy in Baghdad on Wednesday, a day after they stormed the outer perimeter, forcing Washington to dispatch extra troops and threaten reprisals against Iran.
The demonstrators, angry at US air strikes that targeted an Iran-backed group and killed at least 25 people, hurled rocks at the building while US forces stationed on the rooftops fired tear gas to disperse them.
But by mid-afternoon, most of the protesters appeared to have obeyed a call to withdraw, issued by the Popular Mobilization Forces (PMF) umbrella group of mainly Shi'ite militia, which said the demonstrators' "message has been heard".
Young men used palm tree branches to sweep the street in front of the embassy compound, while others packed up equipment and vans arrived to take people away. Some left to set up a protest camp in front of a nearby hotel.
The protests mark a new turn in the shadow war between Washington and Tehran playing out across the Middle East. US President Donald Trump, who faces re-election in 2020, on Tuesday threatened to retaliate against Iran but said later he did not want to go to war.
The unrest was prompted by air raids launched by the United States on Sunday against bases of the Iran-backed militia Kataib Hezbollah in retaliation for missile attacks that killed a US contractor at a base in northern Iraq last week.
Crowds rallied on Tuesday to protest, chanting death to America, setting fires, throwing rocks and smashing surveillance cameras. They breached an outer perimeter of the heavily guarded embassy but did not enter the main compound.
The huge embassy, built along the banks of the Tigris River in central Baghdad's fortified "green zone" during American occupation following the 2003 invasion that toppled Saddam Hussein, is the biggest US diplomatic mission in the world.
Washington says its diplomats are safe and it is rushing hundreds of extra troops to the region.
Overnight, demonstrators pitched tents and camped outside the embassy walls. On Wednesday morning, they had brought in food, cooking equipment and mattresses, suggesting plans to stay, though these seem to have been put on hold.
The anti-American action comes after months of protests in Iraq against the government and the Iran-backed militias which support it. Many Iraqis complain that their country has become a battlefield for a proxy war for influence between Washington and Tehran, and their leaders are too beholden to outside powers.
Iraq's government has long faced tension in its close relations with the two foes. Trump spoke to Prime Minister Adel Abdul Mahdi on Tuesday and demanded Iraq protect the embassy.
Iran's Supreme Leader Ayatollah Ali Khamenei on Wednesday condemned the US attacks. Iran summoned a Swiss envoy, who represents US interests in Tehran, to complain about what it described as "warmongering" words from Washington.
Trump accused Iran of orchestrating the violence at the US embassy and said Tehran would be held responsible.
US officials said 750 extra troops would initially be based out of Kuwait and as many as 4,000 troops could be sent to the region in the coming days if needed.
More than 5,000 US troops are stationed in Iraq supporting local forces. The air strikes have galvanised calls inside Iraq to expel them.
Many in the crowd said the expulsion of US troops and ending Washington's presence in Iraq was their main goal.
Despite decades of enmity between Iran and the United States, Iran-backed militias and US forces found themselves on the same side during Iraq's 2014-2017 war against Islamic State fighters, with both powers helping the government recapture territory from militants who had overrun a third of Iraq.
Since then, US troops have yet to leave, while the Iran-backed militias have been incorporated into the security forces.
Abdul Mahdi, who has already announced plans to step down in the face of anti-government protests in which more than 450 people were killed, is backed by Iran and its allies.
They may have decided to pull back from the confrontation at the embassy to avoid making him look weak, or to avert open clashes with government forces.
"Our sit-in is eternal, until this devil's den is closed off forever, but don't give anyone an excuse to make your protest violent. Don't clash with security," one protest leader told the crowd from a stage erected at the embassy.
Young men, some in fatigues, waving militia flags chanted "Death to America" as Apache helicopters circled above. The embassy's outer walls bore scorch marks and graffiti.
"Iraq is not safe for America and its followers," one read.
Protesters and militia fighters are seen withdraw from the perimeter of the U.S. Embassy during a protest to condemn air strikes on bases belonging to Hashd al-Shaabi (paramilitary forces), in Baghdad