For almost two years, US-backed Iraqi government forces, along with Kurdish Peshmerga forces and other allies, fought to push ISIL fighters out of the country.
One of the key actors, who played a major role in the campaign declared by Iraqi Prime Minister Haider al-Abadi, were Shia-dominated paramilitaries.
Roughly 63 factions make up Iraq's Popular Mobilisation Forces (PMF, also known as PMU) - an umbrella of groups rallied by ethnic and tribal leaders, whose fighters are either loyal to religious scholars, Iraqi political leaders, or Iran's Revolutionary Guard Corps (IRGC).
The diverse makeup of the PMF's 40 divisions - comprising more than 60,000 fighters - sheds light on many of Iraq's sectarian tensions and its ambiguous political future.
Although formed via a religious decree to fight ISIL in 2014 by Grand Ayatollah Ali al-Sistani, Iraq's top Shia religious scholar, many of the fighters are empowered by Iran and other non-state actors. Some have existed for decades prior, and others have political representation in parliament.
The PMF is largely outside government control, yet the Iraqi parliament formally recognised it as a state-affiliated institution when its own forces became depleted in the fight against the Islamic State of Iraq and the Levant group (ISIL, also known as ISIS).
There are three main distinct factions in the PMF with various ideological underpinnings: those loyal to Iran's supreme leader, Ayatollah Ali Khamenei; those loyal to Iraqi popular Shia religious leader Muqtada al-Sadr, who heads the Peace Brigades; and those loyal to Sistani.
All of these groups have become the most powerful military force in Iraq, according to analysts, and some are aligned with Iran to various degrees since ISIL leader Abu Bakr al-Baghdadi stood at the pulpit of Mosul's Grand al-Nuri mosque and announced the creation of a Sunni caliphate.
Since the PMF is not a single unified body, its various factions operate under the policy recommendations of different heads.
The PMF has not publicly demanded political recognition in Baghdad due to the absence of government control and the involvement of non-state actors.
However, two main groups already have political recognition and are members of the Iraqi parliament.
The Badr organisation, which is part of a coalition - the National Iraqi Alliance (NIA) - is headed by former Iraqi Transport Minister Hadi al-Ameri.
Out of the Iraqi parliament's 328 seats, the NIA holds 183 seats, 22 of which belong to the Badr organisation.
The Badr organisation was well established in Iraq's political system prior to 2014, and before entering the realm of politics was previously known as the Badr Brigades, Iran's oldest proxy in Iraq.
The other, Asa'ib Ahl al-Haq, is a Shia armed group founded by Qais al-Khazali. One member of the group is currently sitting in parliament, Chatham House fellow Renad Mansour told Al Jazeera.
"These [groups] will continue to be involved in politics," he said.
Basically, the PMF became an umbrella for anyone who wanted to fight ISIL … There is no standard process to say ok, you are now part of the PMF - it's a loose term.
Renad Mansour, Chatham House
Considered to be the senior, de-facto leaders of the PMF, Ameri and Khazali have established close ties to the PMF's administrator, Abu Mahdi al-Muhandis, who works in alignment with the two and is among the PMF's leadership.
Muhandis is an Iraqi military commander who leads organisations close to Iran's Quds Force, an IRGC offshoot that oversees operations overseas. Like Ameri, he is considered to be among the top military leaders who have maintained close ties with Tehran.
"There is no question that someone like Hadi al-Ameri definitely has political ambition. He was upset when he wasn't made interior minister by Abadi a few years ago, but continues to influence the Ministry of Interior because the Badr organisation has a lot of influence in that industry," Mansour said.
"And they have good relations with Nouri al-Maliki, the former Iraqi prime minister, and he created the PMF."
According to Mansour, who frequently travels to Iraq, it has become clear that Ameri's popularity in the Badr organisation increased significantly through the fight against ISIL.
"When we used to go to Baghdad, we'd see big posters with pictures of martyrs and the logo of the organisation - so basically, using the fight against ISIL, and using slogans like 'we defended Iraq, we defended Baghdad, from Daesh [ISIL]', either way to gain political favour," he said.
"But at the same time, Abadi's influence has also grown, so it's a struggle between these two spheres of influence."
Facade of control
Similarly, Middle East Forum analyst Aymenn Jawad al-Tamimi told Al Jazeera that various PMF factions have been fighting to expand their political influence.
"The idea is to gain ground for the 2018 parliamentary elections, using the victory over the Islamic State, preserving Iraq's unity and restoring security as playing cards," he said.
Despite this, many other smaller PMF factions who emerged in 2014 remain weak, although political ambitions among them cannot be ruled out, Tamimi said.
Prior to becoming a state-recognised institution, the PMF received much of its budget from Iran. Currently, the PMF reportedly receives about $1.5bn a year from Abadi's government - but Muhandis, the PMF's administrator, decides where to allocate the funds.
"The government doesn't have much control over it," Mansour said.
The lack of transparency with budget management has resulted in smaller factions claiming they have not received salaries. Some, said Mansour, have accused Muhandis of favouritism.
Since taking office in September 2014, Abadi has worked on developing Iraq's security sector and has succeeded in revamping "three or four divisions, including the police", Mansour said, "but he needs the PMF as well … that's why there is still a role for the PMF".
According to Tamimi, Abadi allowed for the recognition of the PMF in hopes of being able to control them.
"The idea of the numbering for brigades, for example, is probably based on the idea that the PMF should not be political, but function as a reserve force of the state," he said.
Tamimi noted that some PMF factions "clearly" have a good relationship with state institutions, but others are tied to pro-Iranian factions, which have an agenda differing from Abadi's.
Where were they before ISIL?
According to Mansour, seven groups existed before the 2014 decree and Maliki's creation of the PMF.
"Some have existed for decades and used to be a part of the Islamic Supreme Council of Iraq, which was Ayatollah al-Hakim's party," said Mansour, referencing the late Iraqi top Shia leader.
Some of the pre-existing groups fought against the United States and the Iraqi state itself, but have since shifted closer towards Iran and Maliki, such as Sadr's Peace Brigades.
Iran realises that Abadi isn't someone they can trust completely, so they need to work with people like Nouri al-Maliki and other PMF leaders to ensure that they have influence on the ground.
When Maliki was in office back in 2010, he grew closer to the Badr organisation and to Khazali's forces - essentially relying on them, Mansour said.
"These seven groups continued to exist in one way or another until 2014, when they created a commission, and then, 50 or so more groups emerged - some of them just local groups, some just gangs and criminal networks, and others tribal forces including Sunnis, Christians, Turkmen," he said.
"Basically, the PMF became an umbrella for anyone who wanted to fight ISIL … There is no standard process to say ok, you are now part of the PMF - it's a loose term."
After taking control of the Kurdish-held province of Kirkuk, Iraqi forces, backed by PMF fighters, defeated Peshmerga forces on the outskirts of the oil-rich city.
Over the past week, Abadi has sought to maintain relationships with neighbouring countries as he visited Turkey, Iran and Jordan, while preserving an alliance with the US - a move Mansour said was aimed at limiting Iranian influence in Iraq.
"Iran realises that Abadi isn't someone they can trust completely, so they need to work with people like Nouri al-Maliki and other PMF leaders to ensure that they have influence on the ground," he said.
According to him, Iran's main objectives are to ensure that Iraq remains stable, and to ensure that whoever is leading Iraq is "loyal, but then again not too powerful at the same time".
While it is unlikely for rival PMF factions to seek political recognition in Baghdad, it is in Iran's best interests for various PMF groups to expand or gain a political foothold "as a means of ensuring Iraq remains an ally of Tehran", Tamimi said.
"From Iran's perspective, it is best to have multiple pro-Iranian Shia factions and have them compete for influence, with Iran acting as kingmaker among the various groups."
Given the country's large Shia population, it is difficult to unite Iraq's Shia behind one ideology or a single ideological group.
In 2014, when Sistani issued the religious decree calling on Iraqis to fight against ISIL, he referred to potential fighters as volunteers. In his statement, Sistani urged fighters to steer away from violence so as not to threaten Iraq's long-term stability.
And, earlier this year, local media reported that his office expressed concern over the actions committed by various PMF subgroups.
"Sistani is against what happened with the PMF, and is against what is largely a misinterpretation of the decree - the misuse and politicisation of it," Mansour said.
As such, both Mansour and Tamimi agreed that the differing loyalties of PMF factions create the possibility of future infighting, as well as infighting for less ideological reasons, such as "control of extortion opportunities in various areas".
Source: Al Jazeera News