The battle for Mosul was a huge military operation to recapture Iraq's second largest city from so-called Islamic State (IS).
Mosul fell to IS in June 2014, with IS leader Abu Bakr al-Baghdadi proclaiming the creation of a "caliphate" from its ancient and now destroyed Great Mosque of al-Nuri.
Thousands of Iraqi soldiers, Kurdish fighters, Sunni Arab tribesmen and Shia militiamen, assisted by US-led coalition warplanes and military advisers, took part in the offensive, which began in October 2016.
Iraqi Prime Minister Haider al-Abadi formally declared victory over IS in the city on 10 July.
He waved a national flag with troops after announcing the "collapse of the terrorist state of falsehood".
Only hours earlier, clashes were still being reported in a small part of Old City, where a few dozen IS militants were still holding out.
IS forces were pushed back into the Old City, which is a densely built-up area interconnected by small alleyways, after being encircled by pro-Iraqi government forces in the western half of Mosul.
Hundreds of thousands of civilians have fled the city, much of which has sustained heavy damage during the eight-month offensive.
How the offensive unfolded
The operation was launched on 17 October 2016 with the aim of retaking Mosul and the swathe of territory in northern Iraq captured by IS militants in 2014.
Progress was initially swift, with pro-government forces advancing from the north, south and east, seizing outlying towns and villages despite strong resistance.
Iraqi special forces first entered Mosul on 1 November 2016.
But progress slowed as troops encountered fierce resistance from IS, including snipers, suicide bombers and shellfire.
By January 2017 eastern Mosul was back under Iraqi government control, who announced its full "liberation".
But the west of the city presented a more difficult challenge. The densely-packed housing and narrow alleyways enabled a relatively small number of militants to target advancing troops with snipers and suicide bombs.
How territory was regained
Analysis by IHS Conflict Monitor shows how IS fighters lost their territory in the face of the government offensive.
Situation on 3 July
Contradictory reports made it difficult to track the progress of the government offensive on the ground.
The maps shown here are based on expert analysis from two different sources, the Institute for the Study of War and IHS Conflict Monitor.
What damage has been caused?
Satellite images show extensive damage to Mosul's infrastructure, buildings and archaeological sites - in particular to the airport and bridges.
The barriers were made out of concrete blocks and other rubble, Stratfor's analysis said, possibly from the walls of destroyed buildings.
Imagery also revealed how the jihadists constructed multiple barricades across key routes into the city, including north of the airport.
Meanwhile, coalition air strikes destroyed all bridges linking the east and west of the city across the Tigris river, with the aim of limiting the jihadists' ability to resupply or reinforce their positions in the east.
In the centre of the city, four of the five main bridges were put out of action in October and November by coalition air strikes, with the aim of limiting the jihadists' ability to resupply or reinforce their positions in the east.
The Old Bridge - the only remaining route open to vehicles in the centre of the city - was then disabled in a US-led coalition air strike at the end of December 2016.
Stratfor images showed how the bridges were damaged.
A US air strike damaged the al-Hurriya Bridge at the eastern end in October 2016, but IS then set up a barrier on the western side, shown below.
In November 2016, a US air strike damaged the Fourth Bridge, but was later rendered impassable by further damage, shown below.
Iraqi military engineers installed a floating bridge across the Tigris river in May, after recapturing eastern Mosul, reconnecting the two halves of the city to facilitate troop deployments ahead of the final assault to dislodge IS.
However, the UN estimates rebuilding the city's basic infrastructure will cost more than $1bn.
Reinstating water, sewage and electricity services, as well as reopening schools and hospitals, would cost more than twice initial estimates, the organisation said.
Ancient mosque destroyed
In June 2017, the ancient Great Mosque of al-Nuri, where IS leader Abu Bakr al-Baghdadi demanded allegiance after declaring a "caliphate", was blown up by IS, according to Iraqi forces.
IS claims the mosque was destroyed in a US air raid.
How have people been affected?
More than 800,000 people have currently fled their homes as a result of fighting in Mosul, according to the International Organisation for Migration.
Most have taken refuge in nearby camps and reception centres. Others have gone to stay with relatives and friends.
Following the recapture of eastern Mosul in January, there was deep concern for thousands of people remaining in the west of the city, with food supplies reported to be very low and clean drinking water in short supply.
The UN said in late January that almost half of all the casualties in Mosul were civilians. At least 2,463 have been killed and 1,661 injured across Nineveh province since October.
UN human rights officials said in June that they had received credible reports of hundreds of civilians being shot dead by IS militants as they attempted to flee the fighting in western Mosul, with reports of others being used as "human shields".
Dozens more have reportedly died in Iraqi and US-led coalition air strikes.
The UN says many of those who have fled Mosul have witnessed the deaths of relatives, friends and neighbours and are suffering from psychological trauma..