WASHINGTON – The fight to expel ISIS from its last shard of territory in Syria may be over. But the United States and its partners still face significant battles against the terrorist group, its affiliates and other networks that are less formally aligned with it elsewhere, in Afghanistan, West Africa and the Philippines.

Even before a U.S.-backed Kurdish and Arab militia ousted the last extremist fighters from the eastern Syrian village of Baghuz on Saturday, ISIS had shifted gears. The organization that once staked out a self-proclaimed caliphate across Iraq and Syria has metastasized into a more traditional terror group — an atomized, clandestine network of cells engaged in guerrilla attacks, bombings and targeted assassinations.

Thousands of U.S. troops are helping the Afghan army and security forces combat ISIS and other terrorist groups in Afghanistan. Armed U.S. drones are hunting ISIS cells in Libya. And U.S. forces are advising and providing intelligence to local troops fighting ISIS in Burkina Faso and in the Philippines.

Thousands of ISIS fighters are also still at large in Iraq and Syria, biding their time to rearm and regroup to strike the same regions again. Many of them slipped out or surrendered when the final wave of civilians fled Baghuz, U.S. commanders and intelligence analysts said.

ISIS has $50 million to $300 million in cash either hidden in Iraq and Syria, or smuggled into neighboring countries for safekeeping, according to a February report by the United Nations. The terrorist group also is believed to have invested in businesses, including fish farming, car dealing and cannabis growing, according to Colin P. Clarke, a senior fellow at the Soufan Center, a research organization.

Military and spy agencies are tracking ISIS fighters who have escaped and returned to North Africa, Europe and elsewhere in the Middle East. Analysts said roughly 1,200 of the extremists have returned to Europe alone.

The group's leadership and foot soldiers see this as a setback, not a defeat," Nathan Sales, the State Department's counterterrorism coordinator, said in a speech this month about the territorial defeat of ISIS. "They're actively working to continue the fight from ISIS' worldwide branches and networks."

Gen. Joseph Votel, head of the military's Central Command, told lawmakers this month about the exodus from Baghuz: "What we are seeing now is not the surrender of ISIS as an organization — but in fact a calculated decision to preserve the safety of their families and preservation of their capabilities."

New York Times