Updated

Iraq's announcement of victory in Mosul effectively shatters the Islamic State group's self-styled caliphate. But a complete territorial defeat will take many more months, and the extremists will likely pose a threat in Iraq, Syria and beyond for years to come.

Here is a look at the Islamic State group, the three-year war against it, and what comes next.

THE SELF-STYLED CALIPHATE

IS traces its roots back to the Iraqi insurgency that followed the 2003 U.S.-led invasion, and includes several seasoned intelligence and army officers who once served under Saddam Hussein. The group formally split from al-Qaida under the leadership of Abu Bakr al-Baghdadi in 2014, after seizing the city of Raqqa and other territory across Syria.

In June 2014 the group overran Mosul, Iraq's second largest city, and pushed south in the direction of Baghdad, eventually seizing much of the country's north and west. At its height, IS controlled more than 90,000 square kilometers (35,000 sq. miles) across Iraq and Syria, according to IHS Jane's, a London-based research group.

Shortly after the fall of Mosul, IS declared an Islamic caliphate and demanded the loyalty of all Muslims, the overwhelming majority of whom view it as an extremist group. At its height, it was a proto-state governed in accordance with a harsh interpretation of Islamic law, with an army of tens of thousands of supporters from dozens of countries.

___

AN INTERNATIONAL CAMPAIGN

A U.S.-led coalition began striking IS in August 2014, and the campaign eventually grew into a massive training and advising effort that has cost more than $13 billion and has some 6,000 U.S. forces stationed at bases across Iraq.

Separately, Iranian-backed militias mobilized in Iraq in the days after Mosul's fall and notched some early victories. But it was the U.S.-led airstrikes and aid that eventually helped Iraq's armed forces to retake most of the territory lost to the extremists.

In Syria, the U.S. has relied on Kurdish-led forces, which have retaken large swaths of northern and eastern Syria from the extremists. Turkey has objected to the alliance, however, viewing the Syrian Kurds as the long arm of an insurgency raging in its southeast, and sending its own forces into Syria last year.

To date, the U.S.-led coalition has conducted more than 22,600 airstrikes in Iraq and Syria. Iraqi forces pushed IS out of Tikrit, Ramadi and Fallujah, as well as dozens of smaller towns and villages, before launching the operation to retake Mosul in October. Today IS holds less than half the territory it once claimed.

Those victories have come at a devastating cost. More than 3 million Iraqis have been displaced by the fighting, and while a third have returned to their homes, many of the rest hail from areas that were completely destroyed by the fighting.

___

ONWARD FROM MOSUL

The victory in Mosul has been cast as evidence that Iraq's military has recovered from the humiliating defeat they suffered when IS overran the city more than three years ago. But the Mosul operation also highlighted their continued reliance on U.S.-led air power in a war that is far from over.

After Mosul, the focus is expected to shift to Tal Afar to the west, which has been encircled by state-sanctioned and mainly Shiite militias that control its airport.

IS still holds the town of Hawija, just 150 miles (240 kilometers) north of Baghdad, which is also encircled, as well as a string of towns and villages along the Euphrates River Valley leading to the Syrian border. On the Syrian side, they hold most of Deir el-Zour, a provincial capital, as well as al-Mayadeen and Boukamal, and much of the vast and arid region along the border.

___

THE FIGHT FOR RAQQA

Another major battle is underway in the northern Syrian city of Raqqa, the de facto capital of the IS group's self-styled caliphate. U.S.-backed and Kurdish-led Syrian forces have encircled Raqqa, breached the first lines of IS defenses and inched closer to the heart of the city.

But as in Mosul, they are facing a determined and well-organized adversary that is willing to fight to the death. IS fighters have become experts at using human shields, suicide attacks and armed drones to pin their opponents down in urban areas. The city is still home to up to 100,000 civilians, which could limit the coalition's use of airstrikes.

Although it is only a fraction of the size of Mosul, the loss of Raqqa would mark a major defeat for IS. The city has been the home of some of the group's most prominent leaders and has been used as a key base to plan external operations. But victory there could still be months away.

___

A LINGERING THREAT

As the group's physical caliphate has crumbled, its insurgent network appears to have remained intact. IS regularly carries out attacks deep behind the front lines in Iraq, and has directed or inspired major attacks in several countries, including the May bombing of a concert in Manchester that killed 22 people.

IS still boasts powerful affiliates in Afghanistan and in Egypt's northern Sinai Peninsula, where an attack on an army outpost last week killed 23 soldiers. It also maintains an online presence that allows it to recruit followers and inspire so-called lone wolf attacks that require no central planning.

The group has proven resilient in the past. Its previous incarnation, as al-Qaida in Iraq, was virtually wiped out by U.S. and Iraqi forces, only to rise from the ashes again. It was given new life by Sunni anger over discrimination by the Shiite-led government in Baghdad, then found a powerful springboard in the civil war in Syria, which is far from over.