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 chanting “Death to America,” throwing rocks, covering the walls with graffiti and demanding 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. 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.
President Trump spoke with Prime Minister Adel Abdul Mahdi on Tuesday about the need to protect Americans and American facilities, a White House statement said.
Secretary of State Mike Pompeo also spoke by telephone with Mr. Abdul Mahdi and President Barham Salih in separate calls, and “made clear the United States will protect and defend its people,” according to a summary of the call from the State Department. It said that 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 that 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 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 in Iraq and accusations that the United States had violated Iraqi sovereignty.
Mr. 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 will be held fully responsible for lives lost, or damage incurred, at any of our facilities,” he said in a tweet. “They will pay a very BIG PRICE! This is not a Warning, it is a Threat. Happy New Year!”
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.
The Pentagon sent 120 Marine reinforcements to Baghdad from Kuwait, roughly the same number sent to the embassy in 2014, when the Islamic State was threatening Baghdad.
Thousands of protesters gathered outside Baghdad’s heavily guarded Green Zone on Tuesday morning 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. Kataib Hezbollah is separate from the Hezbollah movement in Lebanon, although both groups are backed by Iran and oppose the United States.
When the protesters pushed toward the entrance to the Green Zone, a district of government offices and embassies in central Baghdad, the Iraqi security forces guarding it did not resist.
Their accession to the protesters was a marked contrast to their treatment of the antigovernment protesters who have been demonstrating outside of the Green Zone for months. Those protesters were met with tear gas and bullets and have not been able to enter the Green Zone.
Once at the United States Embassy, the protesters used long poles to shatter security cameras. They covered the compound walls with anti-American graffiti and set 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 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.
The embassy in Baghdad and an American consulate in Erbil, in northern Iraq, now have a combined staff of 486 people, with the majority in Baghdad.
The scenes there on Tuesday 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 ruled large areas of Iraq.
Iraqi militias, known as the Popular Mobilization Forces, were 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 a number of civilian contractors. The troops are stationed primarily at a base in Anbar Province, northwest of Baghdad, and at another in the Kurdish-controlled north of country. Their task is to train Iraqi security forces and help 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 American 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.