Iran-backed militias withdrew from the compound of the US embassy in Baghdad after Washington threatened action against Tehran for its alleged role in the incident earlier this week.

Iraq is the second largest producer within Opec. Rising tension between the US and Iran and internal unrest are posing a threat to oil operations.

The protesters also dismantled their tents outside the Green Zone in Baghdad on the edge of the Tigris River, the Iraqi Ground Forces Command said in a statement.

The US ambassador to Iraq and other staff had earlier been evacuated from their embassy in Baghdad for their safety.

The Hashd al-Shaabi group, or Popular Mobilisation Forces, an umbrella group of various Iran-backed militia groups, urged protesters on Wednesday to vacate the premises.

“We call on the crowd in front of the US Embassy to respect the call of the Iraqi government and to withdraw from the area for the protection of state institutions.”

The statement went on to say that the protesters had been able to deliver their message to the Iraqi government over their deep resentment against US airstrikes on Kataib Hezbollah militia, which is part of the group.

On Tuesday, thousands of Iraqi protesters stormed the embassy compound, protesting Sunday’s airstrikes in Iraq and Syria against the Kataib Hezbollah militia, which killed at least 25 fighters.

That airstrikes were in response to a rocket attack Friday on an American military base in Kirkuk, blamed on Kataib Hezbollah.

Friday's attack killed one US contractor and wounded four US service members.

Iraqi Prime Minister Abdul Mahdi on Tuesday condemned the airstrikes on Iraqi military elements but also warned those taking part in funeral marches to stay away from foreign buildings and compounds.

"Iraqi security forces will respond to any act of aggression or harassment against foreign embassies in Iraq, and those responsible will face the full force of the law," Abdul-Mahdi said on Twitter.

US President Donald Trump on Tuesday said that Iran will pay a heavy price for any attack on the embassy in Baghdad. Iran has dismissed the US threats as empty bluff.