“In the past two months alone there have been 11 attacks on Iraqi bases that host coalition forces,” said a second senior State Department official who, like the first, spoke to reporters on condition of anonymity. “We’ve voiced our concerns with senior Iraqi officials repeatedly. We’ve asked them to arrest and bring to justice the perpetrators. … There’s just been too many attacks on American and Iraqi forces” by Iranian-backed groups.

The officials said the U.S. warned the Iraqi government that the retaliatory airstrikes were coming before they launched F-15 strike planes to bomb Kataib Hezbollah weapons storage sites and command posts at three locations in Iraq and two in Syria. But the Iraqi National Security Council issued a statement Monday condemning what it cast as attacks against Iraqi government forces, which it referred to as the “45th and 46th Brigade.” The militias are formally part of Iraq’s security forces, known as the Popular Mobilization Forces.

“The Iraqi government condemns this action and promises it [is] in violation of the sovereignty of Iraq,” the Iraqi government statement said, claiming that the Kataib Hezbollah forces that were struck by U.S. aircraft were “holding an important front on the border” against the Islamic State and calling the slain militiamen “martyrs.”

The “sinful attack” by U.S. aircraft “leads Iraq to review the relationship and security, political and legal conditions in order to preserve the sovereignty and security of the country, protect the lives of its children and promote common interests,” the statement said.

The U.S. maintains about 5,000 troops in Iraq at Baghdad's invitation, helping local troops fight the Islamic State insurgency. With that few troops, the U.S. military relies heavily on the Iraqi government for protection, according to Michael Knights, an Iraq analyst at the Washington Institute for Near East Policy.

In earlier phases of the Iraq conflict, U.S. troops fought Kataib Hezbollah and other Iranian-backed Shiite militias while they were also battling Sunni insurgents. The Pentagon blames the militias for the deaths of more than 600 U.S. troops from 2003 to 2011. After the U.S. began fighting ISIS, American troops found themselves at common cause with the militias as Iranian advisers helped the irregular groups fight the caliphate while U.S. advisers helped Iraq’s formal military do the same thing.

But since the liberation of ISIS' urban strongholds in Iraq, tensions between U.S. troops and the militias have grown steadily this year as rocket salvos struck bases where U.S. troops live. Until last spring, the attacks were usually ineffective, and even "aimed to miss," Knights said.

The U.S. government has been “open and clear from May onwards about what the consequences would be if an American was killed in one of these attacks,” said Knights, referring to an earlier warning from Secretary of State Mike Pompeo. “In the intervening months the Iraqi government has done next to nothing to protect our facilities," and the militias have ratcheted up the scale and accuracy of the rocket attacks.

Pompeo repeated that warning during an appearance Monday on "Fox & Friends."

“They took a strike at an American facility. President Trump’s been pretty darn patient, and he's made clear at the same time that when Americans’ lives were at risk, we would respond, and that’s what the Department of Defense did yesterday,” Pompeo said.

The State Department officials said the airstrikes, which are reported to have killed Iranian military advisers along with Iraqi Shiite militiamen, were also meant as a signal to Iran.

“President Trump directed our armed forces to respond in a way the Iranian regime would understand, and this is the language they speak,” the second official said. “It’s been a feature of Iran’s expansionist foreign policy to conduct deniable attacks. We are not going to give Iran the fiction of deniability any longer.”

The U.S. is “not looking for any conflicts in the Middle East,” that official said, adding that “if there’s any further escalation, it lies directly at the feet of Iran’s proxies in Iraq, not on us.” But the officials wouldn’t rule out the possibility of more retaliatory strikes.

“If we don’t respond, it will invite further aggression,” the official said.

The incidents illustrate Iraq's difficult position amid the Trump administration’s “maximum pressure” policy against Iran. Since the U.S. toppled Saddam Hussein in 2003, Iran and Iraq have rebuilt their diplomatic and economic relationship.

Tehran and Baghdad signed several preliminary deals this year covering sectors such as oil, health and trade, as well as plans for a railway link. Iraq views Iran as an important partner to help its economy, while Iran hopes Iraq can help it weather the sting of U.S. economic sanctions.

Iraqi politicians have tried to balance their relationship with Iran and the United States, but it is often a precarious effort. Their struggle is echoed in other Middle East nations, such as Lebanon and Qatar, where Washington and Tehran try to project influence.

“Iraq has repeatedly stressed its rejection … of a conflict or a party to any regional or international conflict and has made hard efforts to prevent friction and reduce collisions,” the Iraqi National Security Council said on Monday.