The storming of the U.S. Embassy in Baghdad by protesters on Tuesday has underscored the vulnerability of U.S. diplomats in a country stuck in the middle of a mounting conflict between the United States and Iran.

U.S. diplomats were forced to hide in safe rooms as Marines flew in from Kuwait to protect them after supporters of an Iranian-backed militia broke through the first layer of security at the compound and damaged a reception area in retaliation for U.S. airstrikes that killed 25 fighters.

For years, Iraq has been caught in a battle for influence between its two principal backers, the United States and Iran. The United States has steadily drawn down militarily following the 2003 invasion of Iraq but hoped to retain influence in the country through its sprawling embassy complex, the largest U.S. diplomatic compound in the world by area.

On Jan. 1, the siege on the U.S. Embassy in Baghdad appeared to come to an end after supporters of the Iranian-backed Kataib Hezbollah militia retreated. (Mustafa Salim/The Washington Post)

But since the spring, the U.S. Embassy has operated on a skeleton crew of diplomats and aid workers, citing threats from Iranian-backed militias.

The reduced footprint came under criticism in an inspector general report issued in November that said the smaller deployment of U.S. officials had “affected all operations of Mission Iraq” and “limited the Mission’s ability to help Iraq become a more resilient, independent, democratic country, and to support counter-ISIS efforts.”

The report also said the work of the U.S. Agency for International Development had been impaired, with just six expatriate staffers in the country to manage $1.16 billion of development, stabilization and humanitarian assistance programs.

Critics of the Trump administration say its “maximum pressure” campaign of economic sanctions on Iran has made conflict more likely and forced the drawdown of diplomats for security reasons. They say the hollowed-out embassy in Baghdad is the primary casualty of that campaign.

“We’ve created a situation where we can’t safely keep people there,” said Ilan Goldenberg, a senior fellow at the Center for a New American Security. “It really does hurt our influence and affects our ability to know what’s going on on the ground.”

Until recently, U.S. officials touted the situation in Iraq as proof that the maximum-pressure campaign was working. Since October, street protests decrying corruption in Iraq included slogans calling for an end to Iran’s widespread influence in the country.

But the killing of 25 people in U.S. strikes aimed at the Iranian backed militia Kataib Hezbollah in Iraq and Syria has infuriated Iraqi leaders and fueled calls for an end to the “American occupation” and “death to America.”

Iraqi leaders denounced the strikes as a violation of Iraqi sovereignty and the rules governing the presence of the about 5,000 U.S. troops based there to help in the fight against the Islamic State.

Overnight on Tuesday, protesters continued to throw molotov cocktails into the embassy compound, forcing diplomats to remain in safe rooms, eating military-grade food supplies, or MREs, while the embassy’s firefighter team put out blazes, officials said.

U.S. officials said the strikes, which injured 50 people, were a response to the militia’s firing of more than 30 rockets against an Iraqi military base near the city of Kirkuk that killed a U.S. contractor and injured four American service members.

A State Department representative said “there are no plans to evacuate Embassy Baghdad,” but analysts think the dire security situation is likely to result in an even smaller diplomatic footprint in Iraq.

The reduced numbers had already limited Washington’s ability to administer U.S. aid in Iraq, send out diplomats to report on the changing political situation and meet with Iraqi leaders and establish strong formal ties.

The Trump administration “has already significantly reduced mainline diplomatic and military personnel from the embassy and, given [Secretary of State] Mike Pompeo’s very public concerns about the safety of U.S. personnel in Iraq, I would not be surprised if there is a further drawdown or repositioning of some of the U.S. diplomatic, military or law enforcement personnel,” said Douglas Silliman, the Trump administration’s previous U.S. ambassador to Iraq.

The State Department declined to say how many U.S. officials are in Iraq. Since May, when Pompeo ordered all non-emergency personnel out of the country, the United States has had 352 direct-hire U.S. citizens and Foreign Service nationals in Iraq, according to an IG report completed last month. The United States also has thousands of American contractors in the country.

A senior State Department official said this month that the number of direct hires in Iraq had gone up from 352 after the end of the six-month ordered departure but declined to specify that figure. Other U.S. officials disputed that account, saying that the State Department has capped direct American hires in Iraq at 300, hampering Washington’s diplomatic capabilities there.

State Department officials conceded that during the ordered departure between May and October, U.S. diplomatic capabilities were significantly downgraded. They say those numbers, however, have increased to acceptable levels but declined to give specifics.

“Current staffing levels are sufficient,” said a senior State Department official, who, like others, spoke on the condition of anonymity to discuss staff numbers, which are sensitive because of security concerns.

The low staffing numbers prompted confusion and questions from diplomats in the State Department about whether the measures were to support cost-cutting efforts or a reflection of an impending U.S. war posture with Iran, three State Department officials told The Washington Post.

Some critics said the U.S. airstrikes were disproportionate to the militia attack and criticized the decision to take credit immediately for the strikes.

“Iran was on its back foot. But these strikes were done clumsily, without coordination with the Iraqis,” said Goldenberg, a former Obama administration official. “The Iranians were trying to provoke this overreaction to change the discussion from Iran to the United States and managed to successfully do it.”

Carol Morello and Philip Rucker contributed to this report.