While their comrades mounted last stands in their Syrian capital of Raqqa and the city of Hawija in Iraq, ISIS terrorists seized the Syrian town of al-Qaryatayn and launched its biggest attack for months in Ramadi late last month. That is the kind of guerrilla insurgency both countries foresee ISIS turning to.
"It is expected that after the Daesh terrorist organisation's capacity to fight in the field is finished, its remnants will resort to this type of (guerrilla) operation. But for a certain period of time, not forever," said a Syrian military source, using an Arabic acronym for ISIS.
The continued ability for ISIS to mount attacks in areas where it was thought to have been eliminated will hinder efforts to stabilise regions when the fighting wanes.
In Iraq, where ISIS originated, it has a proven record of falling back upon local networks from which it can rise anew when conditions allow. So far, it has not shown it has the same capacity in Syria, and it might find doing so more challenging there than in Iraq.
The sectarian divisions on which it thrives are less pronounced in Syria, and it faces competition there for jihadist loyalty from other powerful terrorist groups.
"Daesh is in essence an Iraqi organisation, it will survive to some extent in Iraq. Syrian members will dissolve in other Syrian Salafi jihadist groups," said Hisham Hashami, an adviser on ISIS to the Iraqi government.
But in both countries it has shown it can exploit holes left by overstretched enemies to carry out spectacular attacks - the one in Syria's al-Qaryatayn most clearly - that spread panic and tie down opposing forces.
It has also proved able to carry out bombings and assassinations in areas controlled by the Iraqi and Syrian governments, US-backed Kurdish militias and rival jihadist rebel groups, signalling an ability to survive underground.
A jihadist from a Syrian rebel faction opposed to ISIS said the group had won enough support among young men to give it a latent capacity to revive.
"I believe that it is possible, given that its ideology has spread widely among the youths, that something new will emerge," the jihadist said, pointing to the highly effective propaganda machine deployed by ISIS over the last three years.
The al-Qaryatayn attack began on the evening of 29 September, when up to 250 terrorists with guns, rockets and mortars spread around the area with "terrible speed", said Ayman al-Fayadh, a resident.
It was particularly alarming because the government had declared al-Qaryatayn safe months ago, and had helped its residents to move back into their homes.
When the jihadists were finally forced out after three weeks of fighting around the outskirts of al-Qaryatayn, they took their revenge, slaughtering scores of its inhabitants. "They were very bloodthirsty and didn't spare anyone," Fayadh said.
The Syrian military source said it took three weeks to retake the town because it was inhabited and the army was trying to avoid civilian casualties.
However, the attack showed how towns in Syria's deserts, where armed forces can be spread only thinly, are vulnerable to ISIS and that such operations can tie down opposing armies.
"People are afraid of Daesh returning," said a Syrian journalist who visited the town this week. "They killed anyone who had taken part in pro-government protests. Bodies had been thrown in streets and in wells."
"They're going to continue to have to look for places where they can plan and finance and resource and launch their attacks from," said Colonel Ryan Dillon, spokesman for the US-led coalition, noting ISIS had often used "sparsely populated areas".
The assault on Ramadi took place three days before. Terroriss attacked Iraqi security forces with suicide car bombs, mortars and machine guns in a city that it had apparently lost months earlier.
The big challenge in both Iraq and Syria is to co-opt the Sunni Arab tribes, or risk a revival of jihadist insurgency.
The Suuni-Shi'ite divide has plagued Iraq since the US-led invasion in 2003 that ignited the civil war. Shi'ite parties backed by Iran have dominated the government and used militia forces against mostly Sunni insurgents.
The Syrian government may have the same problem. It is allied to the region's main Shi'ite powers - Iran and militia groups such as Lebanon's Hezbollah - and led by a president, Bashar al-Assad, from a Shi'ite offshoot sect.
It will also be a challenge for the US-backed Syrian Democratic Forces (SDF) alliance in northern Syria, which is spearheaded by Kurdish groups. They have sometimes struggled to convince Arabs that it will protect their interests.
"It all depends on the degree to which those fighting under Assad and the SDF incorporate settled tribes into governing structures," said Andrew Tabler, a fellow at the Washington Institute for Near East policy.
Even in northwestern Syria, where rebel groups including jihadist factions hold sway, hardship and insurgent infighting might create space for ISIS to again seize ground.
Beside the al-Qaryatayn attack, a group of ISIS fighters have managed to take a pocket of territory in rebel-held areas near Hama in recent weeks, battling a rival jihadist group for control of several villages.
It has used bomb attacks and assassinations to target government-held cities in the west, Kurdish security forces in the northeast and Islamist rebel factions in the northwest.
In the isolated enclave it holds in Yarmouk camp south of Damascus, it has also shown renewed aggression, taking over the headquarters of a neighbouring rebel group this month by force.
The jihadist rebel said he believed ISIS could repeat the strategy it used in Iraq last decade of retrenching when under attack, then rebounding in more virulent form.
"In this period of weakness, ISIS depends on the ideology that it spread," the jihadist said.
"It appears that the same experience is being repeated. They could carry out bombings, a guerrilla war."
(Reporting By Tom Perry and Sarah Dadouch in Beirut and Maher Chmaytelli in Baghdad; Writing by Angus McDowall; Editing by Larry King)
For the latest News & Live Updates on Election Results from each assembly constituency in Madhya Pradesh,Rajasthan,Mizoram,Chhattisgarh,Telangana, like us on Facebook or follow us on Twitter for updates.