Kataib Hezbollah, the militia targeted by American fighter bombers, is regarded as the most potent of the dozens of militias, mostly Shiite and backed by Iran, that were assembled into an umbrella organization, the Popular Mobilization Forces, to fight ISIS under the auspices of — and with salaries paid by — the Iraqi Army. But Kataib Hezbollah, whose commander once fought against American troops and now ranks among the most powerful men in Iraq, is also a sworn enemy of the United States, which has 5,000 or so troops and an unclear number of civilian contractors in Iraq to train security forces and prevent a jihadist resurgence. The militia would like to see the Americans driven out and Iran’s influence in Iraq unchallenged.

Another part of the equation is that Iraq has been weakened by months of violent demonstrations, which have forced the resignation of Prime Minister Adel Abdul Mahdi, setting off a power struggle. One target of the demonstrations has been the power wielded by Iran-backed militias in Iraq, and Kataib Hezbollah may have correctly gambled that provoking the United States into airstrikes inside Iraq would divert popular passions toward anti-American actions.

Iraq, lacking a functioning government, now finds itself trapped in a fray over which it has little control, compelled by public indignation to denounce the American airstrikes on its territory but loath to lose the American counterbalance to Iran and its proxies. Iran, apart from its political calculations in Iraq, is also struggling under American economic sanctions and would no doubt like to make America’s hostility as costly as possible for the Trump administration.

After Mr. Trump loudly pulled out of the Iran nuclear deal and imposed tough sanctions on Iran, it is hard to see what incentives he could dangle to prevent Iran and its proxies from further complicating the task of American forces in Iraq or elsewhere in the Middle East. The president could conceivably lessen tensions by opening some form of dialogue with Iran, whether about a possible renegotiation of the nuclear deal or resolving conflicts in Yemen or Syria.