BAGHDAD — Protesters broke into the heavily guarded compound of the United States Embassy in Baghdad on Tuesday and set fires inside in anger over American airstrikes that killed 24 members of an Iranian-backed militia over the weekend.
The protesters did not enter the main embassy buildings and later withdrew from the compound, joining thousands of protesters and militia fighters outside who chanted “Death to America,” threw rocks, covered the walls with graffiti and demanded that the United States withdraw its forces from Iraq.
The situation remained combustible, with protesters vowing to camp indefinitely outside the sprawling compound, the world’s largest embassy of any nation. Their ability to storm the most heavily guarded zone in Baghdad suggested that they had received at least tacit permission from Iraqi security officials sympathetic to their demands.
Secretary of State Mike Pompeo spoke by telephone with Prime Minister Adel Abdul Mahdi and President Barham Salih in separate calls on Tuesday, and “made clear the United States will protect and defend its people,” while the Iraqi leaders “assured the secretary that they took seriously their responsibility” to safeguard American officials and property.
The State Department said that American personnel were safe and there were no plans to evacuate the embassy.
The ambassador, Matt Tueller, had been traveling and was not at the embassy when it was breached on Tuesday, the State Department said in a statement.
The American airstrikes on Sunday have resulted in the most serious political crisis in years for the United States in Iraq, stoking anti-Americanism and handing an advantage to Iran in its competition for influence in the country.
The airstrikes targeted an Iranian-backed Iraqi militia, Kataib Hezbollah, which the United States accused of carrying out a missile attack on an Iraqi military base that killed an American contractor and wounded American and Iraqi service members. A spokesman for the militia denied involvement in the attack.
But the size of the American response — five strikes in Iraq and Syria that killed two dozen fighters and wounded dozens of others — prompted condemnation from across the political spectrum and accusations that the United States had violated Iraqi sovereignty.
President Trump quickly blamed Iran for both the death of the American contractor and the storming of the embassy compound, which he described as “an attack,” adding that the Iraqi government shared responsibility for the compound’s safety.
“Iran killed an American contractor, wounding many. We strongly responded, and always will,” he wrote on Twitter. “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!”
The United States military made a show of force in response to the turmoil, with helicopter gunships circling overhead. From inside the compound, loudspeakers warned the crowd outside to keep away from the walls.
Defense Secretary Mark T. Esper said in a statement: “We are sending additional forces to support our personnel at the embassy. As in all countries, we rely on host nation forces to assist in the protection of our personnel in country, and we call on the government of Iraq to fulfill its international responsibilities to do so.”
The added American forces will be 120 Marines, a defense official said — roughly the same number sent to the embassy in 2014, when the Islamic State was threatening Baghdad.
The embassy complex, which opened in 2009 and cost an estimated $736 million to build, covers 104 acres, nearly as big as Vatican City, the world’s smallest country. By 2012, nearly 16,000 people worked there — most of them contractors, but also diplomats, military personnel, intelligence officers and aid workers — but the staff declined sharply over the following years.
In May, during a period of heightened tensions, Mr. Pompeo ordered most non-Iraqi employees of the embassy in Baghdad and the consulate in Erbil, in northern Iraq, to leave the country.
Thousands of protesters marched into Baghdad’s heavily guarded Green Zone on Tuesday after prayer services for the militia fighters killed in the American strikes. While few of them were armed, many were members of Kataib Hezbollah and other fighting groups that are technically overseen by the Iraqi military. The militia is separate from the Hezbollah movement in Lebanon, although both groups are backed by Iran and oppose the United States.
At the United States Embassy, protesters used long poles to shatter security cameras, covered the compound walls with anti-American graffiti and lit a guardhouse on fire. After breaking open a compound entrance, dozens of men entered and lit more fires while embassy security guards watched them from the embassy roof and fired tear gas.
One group of protesters ended up separated from United States troops by only a pane of glass, according to a video shared on social media. It was not immediately clear how many Americans were inside the compound, but officials said they sheltered in place and were unhurt.
The scenes stirred memories of the seizure of two searing, politically consequential events in recent American history: the seizure of the embassy and 52 hostages in Tehran during the Iranian Revolution in 1979, and the assault on a United States diplomatic compound in Benghazi, Libya, in 2012.
As a congressman, Mr. Pompeo became a political star among Republicans for blistering criticism of Hillary Clinton, then the secretary of state, over the Benghazi attack, which killed four Americans, including Ambassador Christopher Stevens.
Former State Department officials and associates of Mr. Pompeo say that he is keen to ensure that American diplomats overseas are kept safe, and mindful of the political damage Benghazi did to Mrs. Clinton. Republican politicians in Washington say Mr. Pompeo, a Trump loyalist, might run for an open Senate seat in Kansas next year, and has presidential aspirations.
On Tuesday, protesters eventually left the Baghdad compound, but some climbed on top of adjacent buildings, where they planted militia flags. Iraqi police and military personnel eventually arrived at the scene, but they did not disperse the protesters.
The Iraqi interior minister, Yassin al-Yasiri, said in an interview near the embassy that American attacks on an Iraqi militia had invited trouble.
“These are the dangerous ramifications of this strike,” he said. “What happened today is the danger that we were afraid of, and that the Americans should have been afraid of.”
Mr. al-Yasiri said he had coordinated with the Iraqi military and the militias to ensure the embassy’s safety and request that the militia members leave the compound.
While the protesters carried the flags of Iraq and a range of militia groups, the most prominent was that of Kataib Hezbollah, the group targeted by the United States.
A spokesman for Kataib Hezbollah, Mohammed Muhi, said his group intended to erect tents in the street in front of the United States Embassy for an opened-ended sit-in to pressure the Americans to leave Iraq.
“We will not leave these tents until the embassy and the ambassador leave Iraq,” Mr. Muhi said.
The upheaval comes at a critical time for Iraq and for the United States’ role in the country. Mass protests in recent months against poor governance have weakened the government and underscored the criticism of Iraqis who feel that Iran has too much sway over the country’s politics.
At the same time, Iran and the United States have been competing for political influence in the aftermath of the battle against the Islamic State, which once covered large areas of Iraq.
Iraqi militias, known as the Popular Mobilization Forces, formed in part to help fight the Islamic State in tandem with the national security forces, a battle that effectively put them on the side of the United States.
They have since evolved into a powerful military and political force with a significant bloc in Parliament. Some of the militias are backed by Iran and use their power to help advance its interests in Iraq.
The United States has about 5,200 troops in Iraq — down from a peak of 170,000 in 2007 — in addition to an unclear number of civilian contractors. The troops — stationed primarily at a base in Al Anbar Province, northwest of Baghdad, and at another in the Kurdish-controlled north of country — are tasked with training Iraqi security forces and helping to prevent a resurgence of the Islamic State.
After years of military and political investment in Iraq, the United States finds itself in a position where few powerful Iraqis are willing to stand up for it and its role in the country.
Condemnation of the recent airstrikes continued on Tuesday. Mr. Abdul Mahdi, the Iraqi prime minister, announced an official three-day mourning period for the men killed in the strikes, which he called an “outrageous attack.”
In a statement, the Iraqi military reiterated the government’s condemnation of the strikes, but called on protesters to stay away from foreign embassies.
“Any attack on foreign embassies or representatives will be firmly prevented by the security forces and punishable by law with the most severe penalties,” it said.
Falih Hassan reported from Baghdad, Ben Hubbard from Beirut, Lebanon, and Alissa J. Rubin from Paris. Edward Wong and Thomas Gibbons-Neff contributed reporting from Washington.