BAGHDAD — Thousands of angry supporters of an Iranian-backed militia chanting "Death to America" stormed entrances to the U.S. Embassy in Baghdad on Tuesday, laying bare the fragility of the U.S. presence in Iraq despite hundreds of billions of dollars and 17 years of investment in the country.

Members of the U.S.-trained Iraqi security forces stood by as supporters of the Kataib Hezbollah militia surged into the usually heavily guarded Green Zone, breached the main embassy reception area and set it on fire.

They hung the flags of their militia on the barbed wire protecting the compound, daubed pro-Iranian slogans on its walls and tossed molotov cocktails onto its lawns. “America is the Great Satan,” they chanted, and “Death to America” — slogans that echoed those of the Iranian revolutionaries who held U.S. diplomats hostage in Tehran 40 years ago.

The demonstrators then set up tents to camp outside for the night, saying they would not leave until all U.S. diplomats and troops had pulled out of Iraq.

As diplomats and staffers huddled together in a fortified safe room inside the embassy compound, the stage seemed to have been set for a potentially long siege that leaves the United States with little room for maneuver.

The Pentagon dispatched about 100 Marines and two Apache helicopters to reinforce security at the embassy, which was opened with much fanfare a little over a decade ago as the biggest and most heavily fortified U.S. embassy in the world, a symbol of America’s vast new influence in Iraq as well as of the threats that have always stalked its presence.

President Trump was defiant, tweeting angrily that Iran was responsible for the siege, because it backed the militia.

“Iran killed an American contractor, wounding many,” Trump tweeted from his Mar-a-Lago estate in Florida. “We strongly responded, and always will. Now Iran is orchestrating an attack on the U.S. Embassy in Iraq. They will be held fully responsible. In addition, we expect Iraq to use its forces to protect the Embassy, and so notified!”

But Tuesday’s events instead seemed to reveal the extent to which Iran emerged ascendant from the aftermath of the U.S. invasion as the chief influencer in Iraq.

The day began with supporters of the Kataib Hezbollah militia converging on the embassy compound to protest the killing of 25 fighters in U.S. airstrikes Sunday. The strikes were carried out in response to the death of the U.S. contractor in a rocket attack against a military base in Kirkuk that the United States blamed on Kataib Hezbollah.

A spokesman for the militia said the intent was for the demonstrators to lay siege to the embassy until the facility shuts down and U.S. diplomats leave Iraq.

But the demonstrators nonetheless smashed their way into one of the facility’s heavily guarded reception areas, breaking down armored doors and bulletproof glass before setting fire to the room.

American guards inside the embassy fired tear gas to keep the militia supporters at bay, and U.S. troops could be seen nearby and on rooftops, their weapons drawn. Embassy civil-defense workers just inside the gates attempted to put out the fires with water hoses.

The demonstrators also smashed security cameras, set two guardrooms ablaze and burned tires. They made a bonfire out of a pile of papers and military MREs (meals ready to eat) found in the reception area, where guards normally search and X-ray visitors.

The embassy’s sirens wailed as the fires sent dense black smoke billowing over the compound.

The Marine Corps released photographs of the reinforcement unit deploying from Kuwait in the dark aboard MV-22 Osprey aircraft. The Marines are assigned to a task force that the service created in the wake of the 2012 attack on diplomatic facilities in Benghazi, Libya, and are primarily infantrymen.

Later in the day, Defense Secretary Mark T. Esper said he had authorized the Army to deploy about 750 additional soldiers to the region in “an appropriate and precautionary action taken in response to increased threat levels against U.S. personnel and facilities, such as we witnessed in Baghdad today.”

The soldiers are from an “immediate response force” with the 82nd Airborne Division designed to deploy quickly in response to crises.

After Secretary of State Mike Pompeo spoke by phone with Iraq’s acting prime minister, Adel Abdul Mahdi, the threat of an imminent invasion of the embassy eased. An Iraqi army commander told the Iraqi security forces to prevent demonstrators from entering the compound. Abdul Mahdi issued a statement appealing for calm, and the security forces formed a cordon to prevent any further incursions.

But the demonstrators remained outside the embassy gates, denouncing America, attempting to tear down razor wire atop the compound’s walls and tossing molotov cocktails over them.

The U.S. diplomats and embassy staffers inside the safe room felt secure, according to two reached by a messaging app. They declined to give details.

It was unclear how many U.S. officials were in the compound. Officials have given different estimates of the number of American full-time staffers in Iraq, ranging from 300 to 352, but have not provided a breakdown of their locations.

U.S. Ambassador Matt Tueller is out of the country on previously scheduled personal travel but plans to return, a State Department official said.

In an interview with Fox News, Pompeo said there were no plans to evacuate diplomats from Baghdad or to withdraw any of the 5,000 troops in the country.

“We’re going to make sure that we do everything we can to keep that facility safe and secure and have the resources to push back against anything that may confront us there,” he said.

In a separate interview with CBS News, Pompeo said he had repeatedly pressed Iraqi officials in phone calls Tuesday to live up to their responsibility to protect U.S. facilities.

But as the day wore on it became increasingly unclear whether the United States could safely retain a diplomatic and military presence in Iraq without embarking on a wholesale confrontation with the militia — and its Iranian backers — now effectively besieging the embassy.

Iraqi leaders, political figures and clerics have universally condemned the U.S. airstrikes that prompted the assault on the embassy, a situation Iran appears to be intent on exploiting, said a former U.S. ambassador to Iraq, Douglas A. Silliman.

Tuesday’s protests, Silliman said, seemed to reflect an effort by “pro-Iranian elements to try to take advantage of what they’re going to define as a disproportionate American response to the killing of an American military contractor and to Iraqi police officials.” He added, “This is not a massive popular anti-American demonstration.”

Rather, he said in an interview in Washington, it “appears to be an attempt by Iran and pro-Iran factions in Iraq to take pressure off of themselves,” because demonstrations in the past few months “have been anti-Iranian and anti-government-corruption and anti-militia.”

The ease with which the demonstrators reached the embassy underscored, however, how little sway the United States now has over the Iraqi government it installed after 2003 and the security forces it trained.

The embassy compound lies inside the Green Zone, which is normally off limits to ordinary people. But thousands walked unimpeded into the zone to participate in the embassy assault. Iraqi security forces mingled with the crowd, and some joined in. One member of the force that guards the zone’s checkpoints was photographed helping militia supporters smash the bulletproof glass at the embassy reception gate.

Many drew comparisons with the Iran hostage crisis in 1979, the prelude to decades of hostility between Iran and the United States.

“From the siege of their embassy in Tehran in 1979 to Baghdad in 2019, history repeats itself,” said Abu Alaa Al-Awalae, who heads one of the Iranian-backed militias that joined in the embassy attack.

Many of the demonstrators wore militia uniforms and carried flags signifying their allegiance to Kataib Hezbollah.

Among the crowd were some of Iran’s most powerful allies in Iraq, including Hadi al-Amiri, leader of the Badr Organization; Qais al-Khazali, who heads the Asaib Ahl al-Haq militia and was once imprisoned by the U.S. military; and Jamal Jaafar Ibrahimi, better known by his nom de guerre, Abu Mahdi al-Mohandes, who spent years in prison in Kuwait for bombing the U.S. Embassy there.

The graffiti scrawled on the embassy walls signified allegiance to Iran: the names of Iran’s supreme leader, Ayatollah Ali Khamenei, and the powerful Quds Force commander, Maj. Gen. Qasem Soleimani. Other slogans simply read: “America get out.”

Sly reported from Beirut. Dan Lamothe, William Branigin, Alex Horton, Carol Morello, Philip Rucker, John Hudson and Paul Sonne in Washington contributed to this report.