The State Department on Friday told US citizens to leave Iraq "immediately," after an American strike killed top Iranian commander Qasem Soleimani in Baghdad.
"Due to heightened tensions in Iraq and the region, we urge US citizens to depart Iraq immediately," the State Department tweeted.
"Due to Iranian-backed militia attacks at the US Embassy compound, all consular operations are suspended. US citizens should not approach the Embassy."
The US announced earlier Friday that it had killed the powerful general in a strike on Baghdad's international airport, in which the deputy chief of Iraq's powerful Hashed al-Shaabi paramilitary force also died.
Tensions with Iraq were already running high after pro-Iranian protesters laid siege the US embassy on Tuesday, reacting to weekend airstrikes that killed at least 25 fighters from the hardline Kataeb Hezbollah paramilitary group.
The strikes were in response to a 36-rocket attack last week that killed an American contractor at an Iraqi base.
The Pentagon said Soleimani had orchestrated attacks on coalition bases in Iraq over the past few months, including on December 27, the day the contractor was killed.
Soleimani "also approved the attacks" on the US embassy in Baghdad, according to the Pentagon.
The US State Department had issued a travel advisory for Iraq on January 1, warning citizens not to travel to the country.
In a separate statement on Friday, the US embassy in Baghdad also urged American citizens in Iraq to "depart immediately" for fear of fallout.
"US citizens should depart via airline while possible, and failing that, to other countries via land," the embassy said in a statement.
American nationals working at Iraqi oil fields were already evacuating the country, an oil ministry spokesman said.
Several had already left on Friday morning and others were preparing to fly out, Assem Jihad told AFP, adding that there was "no impact" on Iraq's oil production.
The number of American staff at fields in OPEC's second-biggest crude producer had already dwindled in recent months as tensions between the US and Iran soared.