Iraqi forces made major gains in the six months since launching the operation to retake Mosul, but the battle for Iraq's second city and the war against the Islamic State group are far from over.
Tough close-quarters fighting in heavily-populated areas of Mosul is still ahead, and IS also holds territory in other parts of Iraq, as well as in neighbouring Syria.
The jihadists will still be able to carry out attacks in Iraq even if they no longer control significant territory, while the impact of the war -- widespread displacement of civilians, cities and towns devastated by the fighting, countless lives disrupted -- will last long after the fighting ends.
Iraqi forces and the US-led coalition supporting them "are nearing the end of the operation to recapture Mosul," said Patrick Martin, Iraq analyst at the Institute for the Study of War.
But "the final neighbourhoods will be the most difficult to recapture, especially the Old City and the remaining neighbourhoods in northwestern Mosul," Martin said.
Progress in the Old City -- a warren of closely-spaced buildings and narrow streets where hundreds of thousands of civilians are thought to reside -- has been difficult and slow.
"You cannot get vehicles in there, so it's gotta be a dismounted operation," Brigadier General Rick Uribe, a senior coalition commander, said of the Old City.
That "makes it very difficult for any offensive manoeuvre in there, but it makes it very easy to defend," Uribe said.
"Sometimes, 50 metres (yards) is a great day," he said of the Iraqi advance.
Iraqi forces launched the Mosul operation in October, moving toward the city from the south, west and north before assaulting its eastern side, which was recaptured earlier this year.
Two special forces units -- the Counter-Terrorism Service and the Rapid Response Division -- have spearheaded the fighting inside Mosul, while soldiers and police have also taken part.
- Lasting IS threat -
Iraqi Kurdish forces were involved in the initial days of the operation but stopped short of the city, while pro-government paramilitary forces were tasked with moving on the IS-held town of Tal Afar, west of Mosul.
After retaking east Mosul, Iraqi forces set their sights on the far side of the Tigris River, which divides the city.
The battle for west Mosul -- which was launched in mid-February -- has taken a heavy toll on civilians, with hundreds killed or wounded in the fighting, and more than 200,000 displaced.
The coalition has said it "probably" played a role in civilian casualties in Mosul, while residents have been caught up in fighting between Iraqi forces and IS, and the jihadists are intentionally attacking civilians in the city.
Losing Mosul would be a major blow to IS, but would not mark the end of the war against the jihadists.
"Just because we're done in Mosul doesn't mean that Daesh is done in Iraq," Uribe said, using an Arabic acronym for IS.
"There's still another significant number of areas within Iraq that will... need to be cleared of Daesh, and... the Iraqi security forces are getting themselves ready for that eventuality -- they know that it's coming," he said.
"We will not leave any area under the control of the terrorist organisation," Brigadier General Yahya Rasool, the spokesman for Iraq's Joint Operations Command, said at a recent news conference.
- Thousands displaced -
IS holds territory in Iraq's Kirkuk province, as well as areas west of Mosul, and in western Anbar province, and also controls territory including the city of Raqa in Syria.
Losing these areas would still not eliminate the threat of bombings and hit-and-run attacks by the jihadists.
Iraqi "successes in Mosul obscure how (IS) has successfully been resurging in other provinces in Iraq," Martin said.
The jihadists have "reconstituted attack capabilities in Diyala and central Salaheddin," he said, referring to provinces where Iraqi forces had largely reasserted control after heavy fighting earlier in the war against IS.
The end of the battle for Mosul will also leave Iraq struggling with thorny political issues including control of recaptured territory in the north that is claimed by both the country's autonomous Kurdish region and its federal government.
And Iraq will still be contending with the effects of the war -- citizens killed, wounded or missing, hundreds of thousands displaced, houses, shops and infrastructure wrecked, children years behind in school -- for years to come.