(AFP) - The White House on Tuesday warned it would hold Iran accountable for any violence attributed to Tehran-allied militias in Iraq that results in damage to US facilities or injures American personnel.

"Over the past few days, we have seen life-threatening attacks in Iraq, including on the United States consulate in Basra and against the American embassy compound in Baghdad," the White House said in a statement.

"Iran did not act to stop these attacks by its proxies in Iraq, which it has supported with funding, training, and weapons."

Three mortar shells hit late Friday the ultra-secure green zone in Baghdad, which houses Iraqi authorities and the US Embassy.

The rare attack -- whose perpetrators remain unidentified -- did not cause casualties or damage, according to Iraqi officials.

"The United States will hold the regime in Tehran accountable for any attack that results in injury to our personnel or damage to United States Government facilities," the White House statement said.

"America will respond swiftly and decisively in defense of American lives."

Since Donald Trump took over the White House in early 2017, Washington has set Iran in its sights, accusing it of seeking to destabilize the Middle East.

The Republican president in May announced that Washington would withdraw unilaterally from the landmark nuclear pact signed in 2015 between Tehran and major global powers.

Iraq has been an initial victim of the US sanctions re-imposed on neighboring Iran, which it relies on for cheap imports.