In the process, dozens of towns and cities in Syria and Iraq have been pulverized, among them Raqqa, Aleppo, Mosul, Fallujah and Ramadi.
The cost of reconstruction -- running into hundreds of billions of dollars -- is far beyond the capacity of whoever rules either Syria or Iraq. The cost to humanity is worse still.
In Iraq, the advance of ISIS -- followed by the operation to destroy it -- displaced more than 3 million people, according to the United Nations. Nearly 600,000 Iraqi children have missed an entire year of education or more, according to the Internal Displacement Monitoring Centre
; thousands have been warped by ISIS indoctrination.
In Syria, the results of the country's brutal civil war are more shocking: 6.5 million people, including 2.8 million children, have been displaced
, according to the UN. In other words, 50 families have left their homes every hour since 2012. A further 5 million have left the country altogether.
As ISIS retreats, al Qaeda resurfaces
The caliphate is gone and ISIS' totalitarian ideology is stained, even among Sunni Muslims who first welcomed it. But extremism will find new breeding grounds in countries where sectarian loyalties dominate, where there is no work, where distrust is endemic and the "middle ground" doesn't exist.
ISIS began as an insurgency; now it's returning to its roots, which are spread deep across the region. The group's most devastating recent attack in Iraq -- in which more than eighty people were killed -- was in a Shia town south of Baghdad, far from the ISIS heartland. It also has cells in Diyala and Anbar.
ISIS' so-called "provinces," however, remain -- including a fully-fledged insurgency in Egypt's Sinai desert, along with camps in Libya and Afghanistan. A relatively new ISIS affiliate was blamed for the killing of four US soldiers in Niger
As ISIS loses ground, al Qaeda is eyeing opportunities in Syria. Within the last few weeks a new group has emerged from among jihadi factions in the northwest Syrian province of Idlib: Ansar al Furqan. Brett McGurk, the US envoy for the anti-ISIS coalition, has dubbed Idlib as the largest al Qaeda haven since the days of Osama bin Laden.
"As these highly experienced AQ veterans still sit in Syria, situated within masses of frustrated jihadists and a growing void of hardliner leadership, only a fool would think that AQ is sitting idly by," concludes the SITE Intelligence Institute, which tracks jihadi movements.
Al Qaeda also has a new flag-bearer: Hamza bin Laden, son of Osama, whose appeal to a new generation of jihadis is growing.
Iran reaps the spoils of the war on ISIS
Sunni militants have long seen the western democracies -- and, by extension, the Gulf monarchies -- as their adversaries. But they have a new enemy: the Shia coalition powered by Iran, which has recruited militias from Lebanon, Iraq, even Afghanistan to fight in Syria. They are fighting what has become a civil war among Muslims.
These contests for recruits and resources play out against the background of a region in turmoil, where alliances are shifting amid overlapping disputes.
Hardliners in Iran are emboldened
by US President Donald Trump's decision not to recertify
the 2015 nuclear agreement. Saudi officials say they expect a new campaign of sabotage by Tehran, in the Kingdom's predominantly Shia eastern province and in cyberspace.
A senior general in Iran's Revolutionary Guards, Qassem Suleimani, visited the Iraqi city of Kirkuk last week to meet one Kurdish faction, the Patriotic Union of Kurdistan. Days later, the PUK left the disputed city
rather than fight the Iraqi army and the pro-Iranian Shia militia known as the Hashd al-Shaabi.
The Hashd have also occupied Sinjar, the homeland of the Yazidi minority in northern Iraq that has suffered so much at the hands of ISIS. The Iranian dream of linking Tehran, Baghdad, Damascus and Beirut in an arc of Shia influence has come a few steps nearer.
Alliances shift as countries jockey for position
Wherever one looks, from the Gulf to the Mediterranean, governments and the multitude of groups they support or oppose are jockeying for advantage as ISIS shrinks. Force, and the threat of superior firepower, remain the currency of the day.
Iran's regional rival, Saudi Arabia, has gone on a weapons-buying spree -- most notably with King Salman's visit to Moscow earlier this month.
Among the Kingdom's purchases was the powerful Russian S-400 radar, even though it already has US Patriot missiles and will soon have THAAD anti-missile interceptors too. Saudi sources said the government has assured Israel that the S-400 will point towards Tehran, not Jerusalem.
Qatar, meanwhile, is edging towards Iran's orbit out of necessity, starved of basic imports from Gulf states as part of the ongoing dispute over its support for radical groups (not least in Syria). That diplomatic crisis remains very much unresolved.
Yemen is a failed state, brought to its knees by civil war and a Saudi offensive against Houthi tribes that are supported by Iran. The al Qaeda franchise in Yemen has freer rein now than it did when the conflict began in 2015.
Despite the fury of the Syrian regime, Turkish troops have entered the country as a buffer between rebel groups in Idlib and the Syrian army. It is a high-risk mission, and whether they will confront or be attacked by jihadi groups there is yet to be seen.
At its zenith in 2015, ISIS was the common enemy. Two years later, the face of terror and the places it inhabits have changed. But across the Middle East, and among the great powers, there's little sign of the political will needed to turn swords into plowshares.