Analysts also said the scale of the American attack — on five sites in two countries with two dozen people killed — made it likely that Kataib Hezbollah would feel compelled to respond and could rally anti-Americanism.

“Is that deterrence, or is this really risking the whole of the U.S. presence in Iraq?” asked Emma Sky, a senior fellow at the Yale Jackson Institute for Global Affairs.

The United States may have been trying to send a message that killing Americans was a red line not to be crossed, said Ranj Alaaldin, director of the Proxy Wars Initiative at the Brookings Institution in Doha, Qatar. But the toll of its attack was likely to yield “more intense and expanded operations” against Americans.

“What the U.S. intended and what the U.S. will get could be two very different things,” he said.

The militia, Kataib Hezbollah, which is separate from the Hezbollah movement in Lebanon, vowed unspecified “retaliation,” and Iran’s Foreign Ministry spokesman, Seyed Abbas Mousavi, said the United States “must accept full responsibility for the consequences of this illegal action.”

How Iran may respond is difficult to predict. If it chooses to escalate, it or its proxies could strike an array of American targets in Iraq, where there are troops on the ground and other Americans living and working.

The United States accused Iran this month of exploiting the chaos in Iraq to build up a hidden arsenal of short-range ballistic missiles there.