A huge operation, involving more than 100,000 Iraqi troops, federal police, Shia and Sunni militias, was launched in October 2016 to recapture the country’s second-largest city.
Mosul had been under Islamic State control since 2014, when it was used as the base by leader Abu Bakr al Baghdadi to declare a caliphate across Iraq and Syria.
Here is a timeline of the operation to recapture Mosul:
4-10 June 2014 Fall of Mosul
Militants from Islamic State began their attack on Mosul on 4 June 2014, after the death of the group’s military leader Abu Abdulrahman al Bilawi near the city on the previous day.
Initially, convoys of pick-up trucks carrying four IS militants entered the city, shooting their way through checkpoints with many of the city’s 25,000 soldiers and police away fighting in Fallujah.
The group infiltrated the city, seizing military vehicles and weapons and crucifying, burning and hanging soldiers.
5 July 2014 IS leader’s sermon
Islamic State leader Abu Bakr al Baghdadi gives a 21-minute sermon at the pulpit of Mosul’s Great Mosque of al Nuri.
The video came days after Islamic State declared a caliphate spanning Iraq and Syria.
In it, he said: “Do jihad in the cause of God, incite the believers and be patient in the face of this hardship.
“If you knew about the reward and dignity in this world and the hereafter through jihad, then none of you would delay in doing it.”
19 August 2014 Fight for Mosul Dam
IS seized the strategically important Mosul Dam, which provides water and power to millions of people down the Tigris River valley, in August 2014.
Kurdish forces, backed by US airstrikes on IS, fought to retake the key facility hindered by roadside bombs left behind by retreating militants.
The US military had warned of the danger of the dam collapsing, with estimates saying 500,000 people in Mosul and Baghdad could be killed if it did give way.
Sky News Special Correspondent Alex Crawford reported from the dam as Peshmerga troops fought with the militants.
2015 US airstrikes begin
A major military operation involving a force of up to 25,000 Iraqi and Kurdish troops to sever supply routes and then recapture neighbouring areas outside the city was planned for the spring.
The US began coordinating airstrikes on Mosul with Kurdish forces to target supply lines and IS positions around the city.
But the offensive was postponed until October 2016 after IS captured Ramadi in May 2015.
21 October 2016 On the frontline
The postponed offensive began in March 2016, with Iraqi troops, Shia and Sunni militias advancing on Mosul from the east.
They faced strong resistance in villages outside, with IS deploying suicide bombers and well as mortars and machine guns.
US-led coalition airstrikes targeted key IS positions around the city as Iraqi forces slowly gained control of the areas surrounding the south and east of Mosul.
Sky News Chief Correspondent Stuart Ramsay was embedded with the Iraqi army’s elite Golden Division, a US-trained special forces unit, as they arrived on the front lines.
The Golden Division was tasked with retaking the city and to rescue civilians.
14 November 2016 IS tunnels uncovered
As Iraqi forces established a foothold in the east of Mosul into November, IS released an audio file apparently from al Baghdadi saying he was “confident of victory” and urging militants not to flee.
Six districts in the east were recaptured after fierce house-to-house fighting.
Troops made painstaking progress as they cleared neighbourhoods once occupied by IS and stayed vigilant for militants hiding among the civilian population fleeing the conflict.
Sky News Correspondent John Sparks reported from Bashiqa, where militants had dug underground tunnel complexes and hideouts to aid them in their battle against Iraqi forces.
15 November 2016 Fight for the Tigris
Alex Crawford reported from the frontline in the Arbajiyah area of eastern Mosul, as Iraqi forces approached the key bridges spanning the River Tigris.
Intelligence gained from captured IS fighters, as well as drones deployed above the city, allowed forces to develop their tactics and create defensive barricades to halt waves of suicide attacks.
As the Iraqi army took control of neighbourhoods, soldiers used loudspeakers to call for men to come out and be “processed” to root out any IS fighters posing as civilians.
January 2017 Eastern Mosul liberated
Iraqi PM Haider al Abadi declared that the east of the city had been “fully liberated” on 24 January after three months of fighting.
He praised the “heroism” of forces involved in the operation to recapture the city and claimed that IS had “quickly collapsed”.
23 February 2017 Mosul airport retaken
Iraqi forces took full control of Mosul airport and a nearby military facility on 24 February, allowing it to be used as a base for operations in the west of the city.
IS militants had put up fierce resistance after federal police units launched the attack, backed by airstrikes and drones.
Mines had been laid throughout the complex as militants withdrew from the airport and back into western districts.
17 March 2017 Escape from a suicide bomb
Government forces besieged IS militants around Mosul’s Old City as they closed in on the historic Great Mosque of al Nuri, where al Baghdadi proclaimed the caliphate in 2014.
Troops seized control of a bridge across the River Tigris ahead of what promised to be an even more difficult operation to clear the narrow streets of the IS-held west of the city.
Stuart Ramsay shared the moment he and his team narrowly escaped a suicide bomb blast as they tried to avoid sniper fire on the front of the offensive in the heart of the city.
Drone footage showed a huge blast as they were forced to shelter inside a vehicle and then run across open ground to get to shelter.
22 June 2017 Great Mosque of al Nuri destroyed
IS fighters blew up the Great Mosque of al Nuri.
Iraqi’s Ministry of Defence said fighters had detonated explosives inside the structures, destroying the mosque and its iconic leaning minaret.
8 July 2017 Fight to the death
Iraqi forces encircling IS fighters meet at the River Tigris. Some militants still remain and pledge that they will fight to the death.
Iraqi commanders said the militants were fighting for every scrap of territory, using snipers, grenades and suicide bombers.
9 July 2017 Mosul ‘liberated’
Iraq’s Prime Minister Haider al Abadi declares that the city of Mosul has been “liberated” from Islamic State.
Dressed in a black uniform, similar to the type worn by Iraqi special forces, he arrived at the city’s airfield and greeted army officers.
Mr Abadi’s office said: “The commander in chief of the armed forces Haider al Abadi arrived in the liberated city of Mosul and congratulated the heroic fighters and Iraqi people for the great victory.”