A RETREAT by Iranian-backed militia forces from the U.S. Embassy in Baghdad on Wednesday defused, at least for the time being, an escalating conflict between the United States and Iran. Yet thanks to the inept and confused actions of the Trump administration, Tehran has won a tactical victory, and it retains the initiative.

Up until last week, Iran was under severe pressure in Iraq from popular demonstrations demanding an end to its influence over the Iraqi government, including through the militias it sponsors. By firing rockets at an Iraqi base on Dec. 27 and killing an American contractor, the Kataib Hezbollah militia changed the subject. The subsequent U.S. airstrikes in both Syria and Iraq on Sunday touched off universal outrage in Iraq and provided pro-Iran militants with a pretext to storm the embassy compound.

Having done little to stop the initial assault, the wobbly Iraqi government induced the militia members to withdraw only after promising a new debate in parliament over whether to order U.S. forces out of the country. Even if legislators reject the proposition, as they have before, Iran has already succeeded in easing the pressure on its own presence in the country. And it can renew hostilities against the 5,000 Iraq-based American troops at any time, knowing that President Trump — as he reiterated Tuesday — has no interest in a new Middle East war.

Mr. Trump got himself into this mess by withdrawing from the 2015 nuclear deal with Iran, despite U.N. certifications of Iranian compliance, and launching a massive sanctions campaign that has badly damaged the Iranian economy. He did so in spite of widespread predictions that Iran would respond by resuming its nuclear activity and by launching attacks across the Middle East against the United States and its allies.

Mr. Trump is understandably reluctant to respond to the attacks; escalating into a war with Iran would be a catastrophic blunder. But that has left him without effective means to answer or deter Tehran’s provocations, other than by applying still more sanctions. Meanwhile, the pressure campaign has brought about neither the Iranian capitulation on nuclear matters that Mr. Trump said he was seeking nor the regime collapse his more hawkish advisers hoped for.

Having overlooked previous rocket attacks, the administration had little choice but to respond when the Dec. 27 strike killed an American and injured others. However, had it limited its response to Syria, where there are ample Iranian targets, it might have avoided the damaging backlash in Iraq. U.S. forces at the Baghdad embassy and in the nearby region have now been reinforced. But the best way to respond to Iranian aggression in Iraq is to encourage political reforms that will limit Iranian influence and that, at least until this week, had considerable public support.

More broadly, Mr. Trump ought to resolve the contradiction between his attempt to crush the Iranian regime and his distaste for further conflict in the region. If he really “want[s] to have peace,” as he said Tuesday, he ought to be seeking a diplomatic exit from the Middle Eastern hole he has dug for himself.

Read more: