Islamic State and the crisis in Iraq and Syria in maps
The jihadist group Islamic State (IS) has been forced to retreat from much of the territory it seized three years ago, under pressure from a variety of Iraqi and Syrian forces.
In Syria, a US-backed alliance of Kurdish and Arab fighters is besieging Raqqa, the de facto capital of the "caliphate" proclaimed by IS. The Syrian Democratic Forces announced on 20 September that its three-month-old assault was now in its "final stages", with 80% of the city captured.
Iraq's second city, Mosul, was declared "liberated" on 10 July, almost nine months after pro-government forces launched a major offensive with air and ground support from a US-led multinational coalition.
Militants were cleared from the rest of Nineveh province at the end of August, after the district of Tal Afar was recaptured.
The victories now leave IS in control of just two areas - around the town of Hawija, north of Baghdad, and around al-Qaim, in the Euphrates river valley close to the border with Syria.
IS still controls large parts of eastern and central Syria.
Interactive See how the area IS controls has changed since 2016
A report in June 2017 by IHS Conflict Monitor said IS had lost more than 60% of the territory it controlled in Iraq and Syria in January 2015.
IS came to the world's attention in June 2014, when its fighters overran Mosul and then moved southwards towards the capital Baghdad, routing the Iraqi army and threatening to eradicate the country's many ethnic and religious minorities.
At its peak, some 10 million people were living in territory under IS control.
The US presidential envoy to the coalition, Brett McGurk, said in July that coalition-supported operations had cleared 65,000 sq km (25,000 sq miles) and freed 4 million people.
How did IS spread across Iraq and Syria?
The jihadists exploited the chaos and divisions within both Syria and Iraq.
IS grew out of what was al-Qaeda in Iraq, which was formed by Sunni militants after the US-led invasion in 2003 and became a major force in the country's sectarian insurgency.
In 2011, the group joined the rebellion against President Bashar al-Assad in Syria, where it found a safe haven and easy access to weapons.
At the same time, it took advantage of the withdrawal of US troops from Iraq, as well as widespread Sunni anger at the sectarian policies of the country's Shia-led government.
In 2013, the group began seizing control of territory in Syria and changed its name to Islamic State in Iraq and the Levant (Isis or Isil).
The following year, Isis overran large swathes of northern and western Iraq, proclaimed the creation of a "caliphate", and became known as "Islamic State".
A subsequent advance into areas controlled by Iraq's Kurdish minority, and the killing or enslaving of thousands of members of the Yazidi religious group, prompted the US-led coalition to begin air strikes on IS positions in Iraq in August 2014.
Exact numbers of casualties from the conflict with IS are not available.
The UN says at least 6,878 civilians were killed in acts of violence in Iraq in 2016 and almost 2,800 up to the end of August - although the true figure is likely to be higher as the organisation has been unable to verify some reports of casualties in the Mosul area.
According to Iraq body count, the total number of civilian deaths in Iraq since 2014 is more than 66,111 to 18 September.
The UN no longer keeps track of casualty figures in Syria due to the inaccessibility of many areas and the conflicting reports from the various parties to the war there.
The Syrian Observatory for Human Rights, a UK-based monitoring group, reported in July 2017 that more than 475,000 people, including 99,600 civilians, had been killed since the uprising against President Bashar al-Assad began March 2011.
Who is fighting IS?
The US-led coalition has conducted more than 12,766 air strikes against IS targets in Iraq since August 2014.
Most attacks have been carried out by US aircraft, but those from Australia, Belgium, Denmark, France, Jordan, the Netherlands and the UK have also taken part.
In Syria, the air campaign began in September 2014. Since then, about 12,850 strikes have been carried out by coalition forces, which include Australia, Bahrain, France, Jordan, the Netherlands, Saudi Arabia, Turkey, United Arab Emirates and the UK.
The number of strikes each month rose steadily in Iraq up to a peak in January 2016 and then began to fall as the number of strikes in Syria increased dramatically, reaching a high of nearly 1,400 in August 2017.
Russia is not part of the coalition, but its jets began air strikes against what it called "terrorists" in Syria in September 2015.
There is little information from official sources about the Russian air strikes. However, the Institute for the Study of War says evidence suggests Russian planes have targeted deep into opposition-held territory, and helped Syrian government forces to retake control of the city of Aleppo in December 2016.
Other countries targeted by IS
With the proclamation of a caliphate at the end of June 2014, IS signalled its intention to spread beyond Iraq and Syria.
IS leader Abu Bakr al-Baghdadi quickly received oaths of the allegiance from jihadist militants in Libya, and within a year affiliates held territory in five countries and had footholds in several more.
By August 2016, IS was reported to be operational in 18 countries across the world, including Afghanistan and Pakistan, according to evidence seen by the US National Counterterrorism Center. It also found signs of what it called "aspiring branches" in Mali, Egypt, Somalia, Bangladesh, Indonesia and the Philippines.
During 2016, IS also claimed attacks in a number of countries, including Egypt, Turkey, Indonesia, France, Belgium, Germany, the US and Bangladesh. In 2017, IS has claimed to be behind at least two attacks in the UK.
The proclamation of the caliphate triggered a surge in the number of foreign fighters travelling to Syria and Iraq to join IS.
A report published in December 2015 by the New York-based security consultancy Soufan Group estimated that 27,000 foreign jihadists had made the trip from 86 countries - more than half of them from the Middle East and North Africa.
The future of IS in Iraq and Syria
The coalition called the victory in Mosul a "decisive blow" against IS. But the group still controls parts of Iraq as well as a large swathe of eastern Syria.
Rebuilding Mosul is being seen as a major challenge for the Iraqi government. One Iraqi official estimated it would cost $1bn, others have put the figure far higher.
The top US commander in Iraq has also urged the government to "reach out and reconcile with the Sunni population" to prevent "ISIS 2.0 from emerging".
UN special representative Jan Kubis said the victory in Mosul provided an "outstanding opportunity for Iraq to rise again strong and united".
In Syria, human rights activists have warned that hundreds of civilians have been killed in the battle for Raqqa, which began in June 2017. A US spokesman said the city, like Mosul, was a "critical element" in the battle against IS.
Palmyra was one of several ancient sites that IS ransacked and demolished. IS fighters were driven out in March 2016 but managed to retake the city in December. It was finally recaptured again in March 2017.
Interactive Use the slider below to compare before and after images
How does IS get its funding?
Oil was once the biggest single source of revenue for IS. The group seized control of many oil fields in Syria and Iraq, and sold oil on the black market.
But revenue has fallen since IS lost control of oil-producing areas in northern Syrian and western Iraq, and US-led coalition and Russian air strikes began targeting oil infrastructure.
Income from taxes and fees has also fallen as IS has lost control of major cities like Mosul and other populated areas.
Money obtained by looting and fines initially increased, especially when IS seized Mosul in 2014, but has since declined.
At one point, IS was reported to be so short of funds that it was imposing random fines for offences like driving on the wrong side of the road.
According to a report by IHS Markit, territorial losses are the main factor contributing to IS's loss of revenue. It says the group's ability to compensate for financial losses by increasing the fiscal burden on the population it controls appears to have reached its limits.
Where are the refugees?
More than 5 million Syrians have fled abroad to escape the fighting in Syria, according to the UN. Most have ended up in neighbouring Turkey, Lebanon and Jordan.
About 950,000 Syrians have applied for asylum in Europe since April 2011, according to UN figures.
The UN estimates there are more than 3 million Iraqis who have been forced to leave their homes to escape the conflict with IS and are displaced within the country.
The battle for control of Mosul led to more than 900,000 people fleeing their homes for nearby refugee camps or relatives' homes.