ISIL began as an offshoot of al-Qaeda in Iraq, which in 2006 became known as the Islamic State of Iraq (ISI). The movement, led by key al-Qaeda figures, played a major role in driving the sectarian conflict that followed the US invasion in 2003.
ISI carried out deadly attacks in the Iraqi capital, Baghdad, during this period, targeting Western-allied tribal leaders and US army posts before eventually being pushed out.
Undeterred, it soon pitched up in Mosul, Iraq’s second-largest city, which it then used as a hub to continue its attacks.
In 2010, al-Baghdadi was named the ISI chief. Two years later, he mandated ISI affiliates to set up an offshoot in Syria – a country that had been forced to contend with its own civil war.
Members of that offshoot, first known as Jabhat al-Nusra, were then integrated into ISIL after a number of defections.
ISIL quickly began to establish its presence over drained, vulnerable, war-torn areas in Syria and Iraq, making it easy for the group to gain both influence and military power.
Meanwhile, in Raqqa, ISIL worked on weakening the Free Syrian Army (FSA), which opposed forces loyal to Syrian President Bashar al-Assad. It eventually ejected the two largest FSA factions at the start of 2014.
At its height, the group carried out massacres and documented them with slickly produced videos circulated online. It beheaded foreign journalists and aid workers, and burned alive a captured Jordanian pilot.
During a rampage through Iraq’s Sinjar region in 2014, it captured thousands of women and girls from the Yazidi religious minority and forced them into sexual slavery. Many remain missing to this day.
The group also used its caliphate as a launchpad for attacks around the globe, including the assaults in Paris in 2015 that killed more than 130 people.
While it imposed an unforgiving version of Islamic law through public beheadings and crucifixions, the group also carried out the mundane duties of governance in its territories, including regulating prices at markets and repairing infrastructure.
Cornered in Baghouz, the group fought fiercely and desperately to hang on to the last shred of territory it controlled, using thousands of civilians, including women and children, as human shields.