Integrating Shia militias into the Iraqi state is a good way to limit their powers and control them.

On November 26, Iraq’s parliament passed a law that formally integrated the Popular Mobilisation Forces (PMF) into the security forces. The umbrella militia organisation comprises a number of disparate militia groups and will now formally function in parallel to the Iraqi military.

These militias rose to prominence because of their battlefield successes against the Islamic State of Iraq and the Levant (ISIL) after the collapse of the Iraqi army in 2014. More than 100,000 Shia fighters (and some Arab Sunnis) mobilised to fill the security vacuum and were helped by a religious edict from Grand Ayatollah Sistani, the leading Shia cleric in Iraq.

The move has been criticised because it is seen as undermining the sectarian reconciliation process and because the PMF has been accused of sectarian atrocities.

Yet, its institutionalisation was a long time coming. The PMF has had long-standing interactions and overlap with the Iraqi state and has worked with federal security forces during the course of the anti-ISIL campaign, including the current operation unfolding in Mosul.

The emergence of Shia militias

Although some of their key components only nominally report to Prime Minister Haider al-Abadi, the PMF was already a government-sanctioned force and around half of its militias are closely aligned with the federal government.

Some of the most powerful (and autonomous) of the militias, such as the Badr Organisation, was established in and by Iran in the 1980s but have been heavily integrated into state security forces over the past decade. Badr head Hadi al-Amiri has held ministerial posts, as have other senior members of the Badr leadership.

OPINION: The PMF in Iraq – fight, then demobilise

These actors thrive when the Iraqi state is dependent on working with sub-state armed groups or where it is unable to constrain the space for violent armed groups to function.

However, the problem is that these militia groups cannot be militarily defeated, not when this will bring greater costs than benefits to a war-ravaged society and weak Iraqi state. Furthermore, they are not going anywhere, any time soon, given their entrenchment in the Iraqi society.

Broadly speaking, two categories of militias dominate the Iraqi political and security climate: militias that were formed in opposition to the former Baath regime in the 1980s and 1990s and who have dominated the Iraqi state since 2003 (such as Badr) and those militias that emerged from the chaos and vacuum that followed the 2003 war (such as the Sadrist movement’s Mahdi Army and its splinter groups such as Asaib Ahl al-Haq).

READ MORE: Fears of sectarian tension as PMUs close in on Tal Afar

While the latter category of militias have been dismissed as criminals and Iranian proxies by the media, commentators and by their rivals in Iraq (including the Shia political class), the fighters and members of these militias come from the generation of destitute Shias whose political consciousness was shaped by the 1990s era of Baathist brutality, anti-Shia policies and extreme poverty.

They were mobilised and given an outlet for their grievances by the Sadrist movement, established by the charismatic Ayatollah Mohammad Sadeq al-Sadr, whose son Muqtada now leads the movement.

The making of these militias is the disorder of the post-2003 political order. The collapse of the state after 2003 paved the way for localised security structures. Communities needed protection, services and leadership. When the state failed after 2003, the Sadrist movement stepped in by establishing local Sadrist offices and local patrols as well as social and religious services.

Numerous Shia militia groups in Iraq are splinters of the Sadrist movement, which imploded after 2003 as a result of disagreements among the Sadrist leadership as well as organisational and administrative challenges.

Despite the splintering of the movement, the Shia militias that have emerged from the movement assert the same moral authority: It was them and their communities that resisted the Baath regime while the Shia opposition and political class enjoyed a life of luxury abroad and returned to Iraq off the back of American and British tanks.

In other words, these militias see themselves as the rightful heirs to the new Iraq.

Needed PMF integration

The institutionalisation of the PMF could help bring some order to Iraq’s atomised security structures by helping to establish limits to their powers. Moreover, a formal integration of Shia militias into the Iraqi state will help to establish a social dialogue and contract that could breed trust and goodwill.

In its absence, there is little to constrain armed groups who have and will continue to acquire fighters and supporters, as well as weapons and money – with or without integration into the state.

Moreover, they will continue to have a patron in Iran that has historically looked to use fragmentation and division as a means of control and influence in Iraq.

Integrating the PMF into the state does not mean the end of Iraq, even if it signals the death knell for the Iraqi military, which has historically suffered from misuse, a credibility deficit and rampant corruption.

The Iraqi state still has plenty going for it. Its counterterrorism forces (known as the Golden Division) have won widespread acclaim across Iraq’s ethnic and religious spectrum. Its 10,000 fighters derived from Kurdish, Arab Sunni and Shia communities have emerged as symbols of national unity and have spearheaded every major battle since ISIL came to the scene two years ago.

Further, guns and money can only do so much for Shia militias, who are looking to national elections in the coming years as a way of acquiring legitimacy and support.

The emergence of ISIL and the PMUs has dramatically altered the political and security configurations in Iraq but has also produced a series of frontline interactions between different forces that are both state and non-state-aligned and between Iraq’s various communities. These can go a long way towards fostering stability, national unity and a national identity. All is not yet lost for Iraq.

Ranj Alaaldin is a Visiting Fellow at Brookings Doha Center. He specialises in Iraq and the modern history of the Middle East and holds a PhD from the London School of Economics and Political Science.

The views expressed in this article are the author’s own and do not necessarily reflect Al Jazeera’s editorial policy.