A few hundred are believed to still be fighting as IS struggles to survive, having lost most of its territory to campaigns by Western-backed Syrian and Iraqi coalition armies.
But what happened to the rest?
Many thousands were certainly killed in the intense fighting, but US experts believe many have survived, posing a formidable threat going ahead.
"The issue is: how many have died? How many are still there and willing to fight? How many have gone elsewhere to fight?" said Seth Jones, director of the International Security and Defense Policy Center at the Rand Corporation.
"How many have given up? I don't think we have a good answer."
International counterterror groups are putting huge efforts into answering those questions, working hard to name, count and track IS foreign fighters.
In France, officials say, around 1,700 people went to Iraq and Syria since 2013 to join IS. Of those, 400 to 450 have been killed, and 250 returned to France.
Foreign Affairs Minister Jean-Yves Le Drian said on December 8 that about 500 are still in the Iraq-Syria theater, and for them it is now very hard to return to France.
But that leaves another 500 whose whereabouts are unknown, many of them with the skills of war, wielding weapons and making bombs.
July 2017: Civilians walk past the heavily damaged al-Nuri mosque as Iraqi forces continue their advance against IS group militants. Source: AAP
'One-way ticket'
Terrorism specialist Bruce Hoffman of Georgetown University estimated during a conference Wednesday that "thousands" have escaped the war zone.
"Today, some of them are most likely in the Balkans, lying low for the time being, waiting for the opportunity to infiltrate themselves to the rest of Europe," he said.
Some have traveled to other jihadist fronts, according to Thomas Sanderson, of the Center for Strategic and International Studies' Transnational Threats Project.
For example, he said, at least 80 IS fighters from Morocco, Russia, Saudi Arabia and Yemen have joined since May the IS-allied Abu Sayyaf insurgents battling government forces in the southern Philippines.
RELATED READING
Philippines declares end to Marawi siege
Local people in the northern Afghanistan province of Jowzjan have told AFP that French-speaking IS veterans -- from France or northern African countries - have recently set up camp there.
And they also have the option of other conflict zones in northern Africa, like Libya, Somalia, Yemen and elsewhere where jihadist groups akin to IS are conducting violent insurgencies.
The defeat of IS on the battlefield in Syria in Iraq did not close off escape routes. IS fighters were able to blend in with civilian refugees or bribe their way to sneak into Turkey.
Many don't have much choice but to continue to fight: they never had a plan to return to their home countries, where they face imprisonment in most cases, according to Jones.
"For many, it was a one-way trip. They wanted to live in the caliphate, permanently. So we don't see a major move back."