The Islamic State (IS) group in 2014 launched a lightning offensive in Iraq, seizing nearly a third of the country before being beaten back by operations there and in neighbouring Syria.
The biggest loss for the jihadists -- who still hold pockets of land and continue carry out deadly attacks -- was that of Iraq's second city of Mosul on July 10, 2017.
On the anniversary of the city's fall, here is a timeline of the group's presence in Iraq.
- Creation -
In an April 2013 recording, the head of the Al-Qaeda-linked Islamic State of Iraq, Abu Bakr al-Baghdadi, announces the creation of a group called the Islamic State of Iraq and the Levant (ISIL).
Al-Qaeda disavows links with the new outfit by early 2014.
- Jihadist breakthrough -
ISIL fighters, backed by former officers of late dictator Saddam Hussein, capture Fallujah and parts of Ramadi, west of Baghdad, in January 2014.
Fallujah is the first major town to fall to the militants since the US-led invasion of 2003 that toppled dictator Saddam Hussein.
In June, ISIL launches an offensive in northwestern Iraq, seizing Mosul and Sunni Arab areas bordering the autonomous Kurdistan region and routing the badly prepared Iraqi army.
- 'Caliphate' proclaimed -
Also in June, IS declares the creation of a "caliphate" in territories it holds in Iraq and Syria, re-branding itself the Islamic State (IS) and declaring Baghdadi "caliph".
In early August, IS seizes several northwestern towns held by ethnic Kurds, including Sinjar. Tens of thousands of civilians flee into the mountains.
Thousands of women and young girls, in particular from the Yazidi minority, are subjected to rape, abduction and enslavement in IS-controlled zones, according to the United Nations.
- US-led coalition -
In August, US warplanes strike IS positions in northern Iraq and then form a coalition of more than 70 countries to fight the group in Iraq and Syria. Washington deploys 5,000 soldiers.
In March 2015, Iraq announces the "liberation" of Saddam's hometown of Tikrit, north of Baghdad, after nearly 10 months under IS rule.
In November, coalition-backed Kurdish forces retake Sinjar.
In February 2016, Anbar provincial capital Ramadi is recaptured and in June, Iraqi forces retake Fallujah.
A week later, an IS attack in Baghdad kills 320 people.
- Mosul recaptured -
On July 10, 2017, Iraqi Prime Minister Haider al-Abadi declares victory in Mosul after a nearly nine-month offensive led by a 30,000-strong federal force backed by coalition air strikes.
In August the last major IS urban stronghold in northern Iraq, Tal Afar, is declared "liberated". It is followed in October by Hawija, one of the few remaining IS holdouts.
- Victory proclaimed -
On December 9 Abadi declares the "end of the war" against IS and says Iraq has "complete control" of its border region with Syria.
Attacks continue, however. In mid-January 2018, a twin suicide blast kills 31 in Baghdad, and in February, IS claims an ambush in the Hawija region that kills 27 pro-government fighters.
In March at least 25 civilians and members of the regime forces are killed in the north.
- Executions -
On June 17, IS fighters attack villages in the desert region of Jazira, west of Baghdad, and abduct 30 people. The bodies of seven are recovered.
On June 27, the army finds the bodies of eight people who had been captured by IS.
Abadi orders the execution of hundreds of jailed jihadists already sentenced to death. Thirteen executions are carried out on June 29.
On July 4 the security forces working with Kurdish fighters launch a vast operation to wipe out IS cells in the centre of the country.