Iraqi security forces advance during fighting against Islamic State militants on the western side of Mosul, Iraq, on Feb. 26. (Khalid Mohammed/Associated Press)

IRAQI GOVERNMENT forces last week launched a crucial campaign to retake the western side of Mosul, the Islamic State’s largest remaining urban stronghold. U.S. planes and special forces were providing critical close-up support for a battle that commanders believe could drag on for months. Victory is not assured and the humanitarian cost, which Iraqi forces managed to minimize in capturing the eastern side of the city, could steeply rise. Yet the biggest challenge looms beyond the immediate battle: whether Mosul and other Sunni-populated areas of Iraq can be stabilized once the jihadists are driven out. Unfortunately, in his first weeks in office President Trump has significantly worsened the chances for success.

The rise of the Islamic State was facilitated by sectarian tensions among Iraq’s majority Shiite and minority Sunni and Kurdish populations, and in particular by the discrimination against Sunnis by a Shiite-led Baghdad government backed by Iran. After the fall of Mosul in 2014 the Obama administration helped to engineer the removal of Prime Minister Nouri al-Maliki, who fomented the sectarianism, and his replacement by the more moderate Haider al-Abadi, who pledged to build a more inclusive regime. Mr. Abadi’s good intentions have mostly been thwarted by sectarian hard-liners, including Iranian-controlled Shiite militia groups.

Consequently, the military offensive to recapture Mosul has gone ahead without accompanying political steps that might strengthen moderate Sunni leaders against militants who will seek to perpetuate an insurgency against the Baghdad government. A report this month from the Institute for Study of War warned, “Early indicators suggest that a post-ISIS Sunni insurgency may be forming in Iraq and al Qaeda (AQ) is trying to gain traction within it.” It said, “the U.S.-backed Coalition has been focused only on eliminating ISIS, not other insurgent groups or the conditions that grow them.”

While the Obama administration deserves blame for sidestepping Iraq’s political challenges, Mr. Trump has quickly exacerbated the trouble. His repeated suggestions that the United States might seize Iraq’s oil fields have alienated forces across the political spectrum, notwithstanding a disavowal by Defense Secretary Jim Mattis. Worse, his inclusion of Iraq on a list of majority-Muslim nations from which visitors and immigrants would be banned has prompted Mr. Abadi’s opponents to demand that Americans — including the more than 5,000 U.S. troops now operating against the Islamic State — be expelled from the country.

Mr. Abadi managed to resist a parliamentary resolution to that effect after that ban was issued. But if Iraq remains on the list of banned nations in a revised order the White House says it is preparing, he could face another political rebellion that could cause his government to collapse. Tehran’s Shiite militias could push to replace U.S. forces in the fight for Mosul; or more likely, Iran’s clients could demand that all American forces leave Iraq immediately after the battle. That would virtually ensure the predominance of sectarian elements among both Shiites and Sunnis and open the door to another resurgance by al-Qaeda or other jihadists.

Mr. Mattis discounted that risk during a visit to Baghdad last Monday, saying, “I imagine we’ll be in this fight for a while and we’ll stand by each other.” A reasonable Iraqi might ask: Why should a U.S. administration that bans all Iraqis from setting foot on American soil be regarded as a worthy partner?