President Obama's two-year-old campaign against the Islamic State is clearly weakening the extremist group. But he's unlikely to finish the job during his final months, leaving it to his successor, Hillary Clinton or Donald Trump, to figure out how to keep ISIS on the run.
U.S.-backed Iraqi troops are on the march against the ISIS stronghold of Mosul in northern Iraq. In neighboring Syria, ISIS recently lost the symbolically important town of Dabiq.
After a string setbacks over the past year, ISIS is on its heels across its self-proclaimed caliphate. The Pentagon says it's only a matter of time before Mosul is back in Iraqi government hands, and most analysts would agree. With greater optimism, the Pentagon also says the Islamic State "capital" of Raqqa, Syria, will fall soon.
The question is, if that all goes as planned, then what?
"What we expect to see in the coming months is success in Mosul, success in Raqqa," said Marine Gen. Joe Dunford, the chairman of the Joint Chiefs of Staff. "But we also know there will be second- and third-order effects from our operations in Iraq and Syria."
Dunford convened a meeting of defense chiefs from dozens of countries this week at Andrews Air Force Base, outside Washington, to begin to discuss the nature of those "effects." Some 50 military leaders attended, and the focus was on "countering violent extremism" centered in the Middle East.
Dunford and other military leaders have called that a "generational problem," one they privately concede the U.S. may never resolve. More pressing is the immediate challenge that will follow the deflation of the self-proclaimed Islamic State, the aftermath of which could be as complicated as its emergence in 2014.
Much to rebuild
Basic reconciliation and recovery will be one of the largest and most visible of Dunford's "second-order effects." American airstrikes and Iraqi ground forces have destroyed large parts of western Iraqi cities as they pushed out ISIS. Iraq is short of cash to rebuild, and while it might get some U.S. help, the tab will be large.
Iraq's Shiite-led government also must determine how it will deal with ISIS prisoners and casualties that survived the fighting, and Iraqis who may have collaborated with them. These are thorny problems in a country with a history of sectarian violence and deep resentment after the war.
Iraqi civilians fleeing Mosul, for example, fear that as Sunni Muslims and onetime victims of ISIS, they could be grouped together with the Sunni terror group and distrusted – or persecuted — as potential sympathizers. One man told NPR's Alice Fordham that ISIS has so poisoned the outlook for Sunnis in Iraq that it "killed the future."
Retired Army Gen. David Petraeus, who commanded the 101st Airborne Division in Iraq among his other jobs as a top military commander, told NPR's Steve Inskeep that jockeying for influence inside Mosul itself will begin almost as soon as the battle is over.
"The question really comes down to post-Islamic State governance," Petraeus said. "The Iraqi government is going to influence this, there's the Kurdish region, there's a Turkish element lingering on the outskirts of the city and ... all of these different elements within it. A number of those have grievances. There will be some that want to settle scores and certainly all of them are going to be competing for power and resources and influence."
A residual ISIS force
And driving ISIS out of Iraqi cities doesn't mean the group will disappear. The Pentagon and its allies are said to be preparing for an ISIS that could live on as an insurgent force in the remote areas of western Iraq where its predecessor, al-Qaida in Iraq, took refuge before.
"There will be insurgents and there certainly are terrorist cells in Baghdad and cities around it," Petraeus said. "We can put a stake through the heart of the [ISIS] army ... but we can't put a stake through the heart of the ideas, and the ideology."
If a new insurgency flares up, Washington might experience a bad flashback.
Iraq's then-prime minister, Nouri al Maliki, was happy to see U.S. forces leave in 2011, when the country was mostly calm. He then pleaded with the U.S. in 2013 for attack helicopters and other advanced weapons to help beat back the ISIS insurgency. Obama increased assistance, but administration officials and other skeptics worried that Maliki's Shiite government would use heavy weapons to crack down on Sunni rivals.
Later, the White House and the Pentagon were dumbfounded after Iraq's army folded in the face of the ISIS surge in 2014, when it captured Mosul and the other territory and announced its caliphate.
The collapse of the Iraqi army, which had been trained and equipped at a cost of some $25 billion after the 2003 U.S. invasion, necessitated a wholesale effort to remake the military.
The question of U.S. forces
The next president also faces a decision about whether to leave behind a residual force of American troops to help Iraq keep its restive areas under control. In 2011, Obama decided the answer was no.
Critics led by Arizona Sen. John McCain have called that choice to pull out of Iraq "an unmitigated disaster," one they charge led to a vacuum of power that, combined with Iraq's internal problems, set the stage for the Islamic State's dramatic rise.
Presidential hopefuls Clinton and Trump were asked what they would do in Iraq at their third and final debate on Wednesday.
Clinton said she believes the U.S. must continue to prosecute the Mosul offensive but she would not support using American forces to try to stabilize Iraq.
"I will not support putting American soldiers into Iraq as an occupying force," she said. "I don't think that is in our interests and I don't think that would be smart to do. In fact ... I think that would be a big red flag waving for ISIS to reconstitute itself."
Trump, however, suggested he would be open to leaving an American force in Iraq. In fact, Americans might even "take the oil" as recompense for the U.S. effort there. Trump says that with some 5,000 American forces committed for now, they can't be withdrawn the way they were before.
"We should have never been in Iraq," he said, "but once we were there, we should have never gotten out the way they want to get out."