Stephen Hadley served as national security adviser during the George W. Bush administration.

The U.S. drone strike that killed the Iranian Quds Force commander, Maj. Gen. Qasem Soleimani, was a bold move with potentially far-reaching consequences. It unquestionably heightens the risk of war; it could also open the door to diplomacy.

But the Trump administration’s immediate challenge is to contain the action’s impact on Iraq.

Soleimani’s killing by U.S. forces outside the Baghdad airport was a nightmarish development for Iraq, which fears becoming the central battleground in the increasingly military confrontation between Iran and the United States. Iraq has struggled to balance its American patron and its Iranian neighbor while preserving its sovereignty. Iranian-backed militia units — Popular Mobilization Forces, or PMFs — played an important role in defeating the Islamic State in Iraq. But since then, the Iraqi government has struggled, largely unsuccessfully, to bring the units under its control.

Violent demonstrations in Iraq over the past several months presented an unexpected opportunity. While protesters challenged the corruption, sectarianism and ineffectiveness of the Iraqi government, they also railed against Iranian influence. That could have strengthened the Iraqi government’s hand in dealing with the PMFs. Unfortunately, Soleimani’s death has diverted attention instead to the presence of U.S. forces.

The Iraqi parliament on Sunday passed a nonbinding resolution asking the Iraqi government to expel foreign troops from the country, targeting the approximately 5,000 U.S. forces in Iraq. But that does not necessarily end the matter. Whether the caretaker government of Prime Minister Adel Abdul Mahdi has the power or desire to eject U.S. and coalition forces is uncertain.

What is clear is that one of the PMFs, Kataib Hezbollah, has been behind the escalating violence over the past several months as part of a campaign (assuredly with Iranian approval) to force out U.S. troops. The campaign culminated in the Dec. 31 attack on the U.S. Embassy in Baghdad. (The head of Kataib Hezbollah, Abu Mahdi al-Muhandis, was killed with Soleimani.)

By expelling U.S. forces, the Iraqi government would be falling into Kataib Hezbollah’s trap: rewarding the militia’s violent campaign, strengthening the Iranian-backed PMFs, weakening the Iraqi government and state sovereignty, and jeopardizing the fight against the Islamic State. Forcing out U.S. troops would not sit well with the Kurdish and Sunni populations in Iraq, nor with the Sunni Arab states, such as Saudi Arabia and the United Arab Emirates, whose support Iraq needs to balance Iran.

The United States can help. Too often it has viewed Iraq exclusively through the prism of U.S. policy toward Iran. The Trump administration should publicly state that it is committed to the sovereignty of Iraq, that the mission of U.S. and coalition troops is to train Iraqi security forces and help them protect the Iraqi people against a resurgent Islamic State, and that the United States will coordinate with the Iraqi government on matters involving U.S. troops.

While doing what’s necessary to protect U.S. military and civilian personnel in the region, the United States should pursue its fight with Iran outside of Iraqi territory. The administration should treat any fresh attacks by Iran or its militias on U.S. forces in Iraq as an opportunity to shift the focus back on Iran as the true threat to Iraqi sovereignty.

Beyond focusing immediately on shoring up U.S.-Iraqi relations, the Trump administration, of course, must contend with the possibility of the conflict with Iran escalating. One can only hope that President Trump succeeds in deterring Iran from its threatened retaliation for Soleimani’s death. But the threat of greater violence is likely to continue unless interrupted by a resumption of diplomacy.

Russian President Vladimir Putin can be expected to mount a diplomatic initiative similar to the one he undertook in 2013 to remove chemical weapons from Syria. President Barack Obama welcomed that development, and Trump is likely to be similarly enthusiastic. Putin may conclude that it is time to bail out his erstwhile Iranian ally from a potential military confrontation with the United States that Iran simply could not win and that could threaten Russian interests in the Middle East.

The European countries that backed the Joint Comprehensive Plan of Action — the nuclear deal between the United States and Iran — may rekindle their interest in promoting peace between the two countries. And America’s regional Arab allies have been privately pushing for a negotiation that would include them and address Iran’s nuclear, ballistic missile and regional activities.

Tehran should embrace a diplomatic solution when it surfaces. The country faces increasing economic hardship that risks reigniting the massive public demonstrations that the regime was able to put down last fall only by a brutal use of force. Iran’s leaders have shown that they can be pragmatic when the regime is threatened. Continued conflict with the United States would almost certainly mean harsher and more-destabilizing economic sanctions.

Trump, like Obama before him, has tried mightily to withdraw U.S. troops from the Middle East. Both failed. The United States remains engaged there because it continues to have vital interests in the region: forestalling terrorist threats; supporting and protecting friends and allies; checking Iran’s nuclear ambitions and malign influence. The killing of Soleimani may result in even deeper U.S. involvement, but it doesn’t have to if the parties choose diplomacy.

Read more: