Analysts say the group is already preparing for a new phase, morphing back into the kind of underground insurgency it started as, when it took root among disaffected Sunni populations that were willing to tolerate, if not wholeheartedly embrace, its ultraconservative brand of Islam. And while many Arabs quickly soured on the group because of its brutal crackdowns and unfulfilled promises, their underlying political disaffection has not been addressed.

Another major concern, now that Islamic State-held territory is reduced, is how countries in Europe, in the Middle East and around the world will handle the foreigners who joined the group in places like Syria and might return home and plan attacks there.

A victory in Raqqa has come at a heavy cost. Much of the city has been devastated by American-led airstrikes that killed more than 1,000 civilians, according to tallies by local activists and international monitors. In earlier years, many were killed by Russian and Syrian government strikes. About 270,000 residents have been displaced by the fighting, and thousands of homes have been destroyed.

Hassan Mohammad Ali, a member of a civilian council backed by the United States and the Syrian Democratic Forces that is supposed to be responsible for rebuilding the city, said last week that reconstruction would be a challenge.

“The city is in ruins; it needs time,” he said. “And it needs prospects that are beyond ours, our energy.” Just providing bread to areas retaken from the Islamic State was stretching the council’s capacity, he said.