Iraqi forces briefly captured Baiji on November 14th, 2014, but were not able to captured the entire city, with IS present in a few neighborhoods. Fighting continued and on December 21 the Islamic State recaptured the entire city and reestablished the siege on the refinery.
The anti-ISIS coalition launched airstrikes on the city when the opportunity presented itself. On 16 January 2015, A patrol of Tornado GR4's, operating near Baiji in support of Iraqi ground forces, attacked three ISIL positions with Paveway IV laser-guided bombs. A fourth position nearby was attacked shortly afterwards. On February 4, 2015, a pair of Tornado GR4's conducted an armed reconnaissance patrol over Baiji in support of Iraqi ground forces. Two ISIL armoured vehicles were identified in a building and were attacked with Paveway IV laser-guided bombs, scoring two direct hits.
In early March 2015, ISIL launched a fresh offensive on the refinery, after some Iraqi troops were redeployed to Tikrit to aid the Iraqi government in the Second Battle of Tikrit. On 7 April 2015, Iranian state news media reported that 60 ISIL militants were reportedly killed by Iraqi forces in the town of Malha, which is close to the oil refinery. On 11 April 2015, ISIL launched another assault on the Baiji oil refinery, capturing much of it.
On April 14, ISIL reinforcements arrived from Raqqa after staying three days in Mosul. Beginning on 14 April, the US-led Coalition escalated its airstrikes in the region. From 14–15 April, the coalition conducted 9 airstrikes in and around Baiji, which struck two large and six smaller tactical units, destroying two ISIL fighting positions and an ISIL heavy machine gun. From 15–16 April, the coalition conducted eight airstrikes in and around Baiji, which struck two large and four smaller tactical units, destroyed two ISIL structures, an ISIL mortar system, an ISIL fighting position, and an ISIL vehicle. From 16–17 April, the coalition conducted five airstrikes in and around Baiji.
Iraqi general Ayub Khalif was killed by IS on April 14 while defending the refinery along with 9 of his men. On April 17, ISIL withdrew from most parts of the oil refinery after suffering high casualties inflicted by well-entrenched Iraqi forces.
From 19–20 April, the coalition conducted eight airstrikes. However, ISIL was still inside the Baiji Oil Refinery on April 23, despite claims by the US and Iraqi governments that the refinery was fully secured. On the same day, Iraqi federal policemen arrived to reinforce Iraqi Army positions. From 25–26 April, the coalition conducted 7 more airstrikes in and around Bayji.
On 27 April, ISIL militants launched another attack on the refinery, destroying three depots and several Iraqi units. The next day, the Islamic State controlled the middle of the refinery. By May 1st, ISIL controlled 60%–80% of the oil refinery. On May 2nd, Iraqi forces killed Abu Ibrahim Chechen, the top Islamic State commander at the battle.
From May 2nd to 4th, the coalition conducted 13 airstrikes in and around Baiji. Airstrikes continued on May 6–7, with the coalition conducting 6 airstrikes in the Baiji area.
Iraqi forces briefly broke the siege on May 10, but ISIL quickly re-entered the refinery and severed all of the supply lines leading to it.
On May 15th, ISIL fighters set fire to fuel storage containers to obstruct advances by pro-Iraqi government forces. ISIS was deeply embedded within the facility and Iraq was reduced to supplying the defenders by air.
On May 22nd, ISIL finally captured the refinery in its entirety. Because of this failure, the US decided to allow Shi'ite militias under the control of the Iraqi Government to join the battle. Parts of the refinery were set on fire during the battle.
On 7 June, Iraqi Security Forces and PMU militias entered the city limits with help from coalition airstrikes, capturing the downtown area of the city. Small pockets of ISIL fighters were present. Two days later, Iraqi forces had captured half of the city. The coalition continued to provide air support. On June 24th, the city was recaptured. On June 29th, Iraqi forces, supported by Shi'ite militias, recaptured the oil refinery. Iraqi forces were clearing the city of IEDs and other explosives left behind by ISIL.
However, a small number of ISIL sleepers were still hiding inside the city and the refinery, ambushing Iraqi fighters and hampering the cleanup process with guerrilla attacks and suicide bombings. The Islamic State continued to conduct larger attacks, forcing the Iraqi military and allied militias to retreat from three neighborhoods on July 5th.
On July 6, ISIL controlled several parts of Baiji with clashes continuing inside the city. Clashes continued the next day. On July 29th, three ISIL suicide bombers attacked a suburb to clear a way for other militants, killing 11 and wounding 21.
However, by the end of the month, the city was almost entirely under government control. ISIL retained control over only the Muhandeseen neighborhood in the eastern part of the city.
ISIS recaptured parts of the city and refinery on September 2nd, undoing many of the gains Iraq made in the previous months. By late September, the battle was stalemated, with the Iraqi army's inability to recapture the city and its refinery considered to be a main stumbling block towards retaking Mosul. ISIL was bringing in fresh reinforcements to replace weary fighters and control more than half of the city. 500 IS fighters were killed in the battle between mid-July and early September 2015.
Iraqi security forces and Shiite militias were primarily entrenched in the south of the city and were unable to cut the Islamic State's supply lines. In late September 2015, Iraqi forces were able to cut the ISIL supply route to Baiji from the west, but were having trouble cutting supply lines from the north.
On 14 October, the Iraqi Army, supported by Shiite militias and the U.S. and Iraqi Air Forces, launched a large-scale offensive to recapture the city and its ruined oil refinery. Iranian Major General Qasem Soleimani masterminded this offensive. Hadi al-Amiri, the leader of the Popular Mobilization Forces, was also in the region.>
On October 16th, Iraqi forces fully recaptured the oil refinery as well as the neighboring town of Al Siniyah. It was reported that there were several thousand Iraqi soldiers and Shi'ite militiamen in the city to carry out the offensive.
On October 17th, Iraqi forces advanced northward from the refinery to Mas'haq, recapturing the al-Hanshii and Baiji Thermal Power Station areas, reducing ISIL control to a pocket in the southern part of the city and a besieged pocket between the Baiji Fuel Depot and the Northern Company Fertilizer Plant. Later on the same day, Iraqi Government forces and Shi'ite militia forces pushed further north, besieging the town of Zawiyah, which was near the last ISIL supply route into Kirkuk Province. At the same time, residents fled ISIL-held villages to meet the Iraqi forces.
Iraqi forces then severed all of ISIL's supply lines and recaptured multiple districts in the area, including the town of Al-Siniyah, reducing ISIL's control of Baiji city to a pocket in the southern 40% of the city. A Coalition spokesman said that the coalition had carried out 43 airstrikes in the Baiji region in the past 30 days.
On October 20th, Iraqi Security Forces and Popular Mobilization Forces recaptured the entire city of Baiji along with the surrounding region. Pockets of resistance continued until October 22nd. On October 21nd, Iraqi forces claim to have uncovered 19 mass graves containing the bodies of 365 ISIL militants killed in the battle. The US conducted a total 130 airstrikes in the Baiji region since August 2015 to support the Iraqi Army and affiliated Shi'ite militias.
On 23 October, Iraqi Prime Minister Haider al-Abadi visited the city of Baiji. He said that Baiji was finally free from ISIL militants, that anti-ISIL forces had won a valuable victory, and that the battle proved the capabilities of pro-Iraqi forces. Shi'ite militias were removing IEDs and landmines left behind by ISIL. The same day, PMU fighters retaliated against the Sunni population by bombing the houses and government buildings of former Sunni Baathist generals who had fought in the Iran–Iraq War.