These days, one can hardly turn a street corner in Baghdad without coming face to face with a poster lionizing one of the more than 100,000 Iraqi Shia fighters who have risen to prominence battling the Islamic State (also known as ISIS), which began its march through the country in June 2014. Among the militias and brigades, the most prominent are a number of pre-existing Iranian-backed groups, including Asaib al-Haq, the Badr Brigade, and Ketaib Hezbollah, which work together under an umbrella militia force known as Hash’d al-Sha’bi (Popular Mobilization Force or PMF). These groups’ popularity came from their success in rolling back ISIS in places like Tikrit, Diyala, Baiji, and Anbar, as well as preventing the jihadis from expanding further in the country. After the collapse of the Iraqi army in 2014, these groups filled the security vacuum and are now seen by many Iraqi Shias as integral to their survival.

Although the PMF is officially under the control of Iraqi Prime Minister Haider al Abadi, and there are large numbers of fighters that operate within the state’s military command and control structures, the strongest and most powerful force on the ground remain those militias that are Iranian-backed and controlled. They constitute the core of the PMF and are battle-hardened fighters who have years of fighting experience. They fought both U.S. and U.K. forces after the 2003 Iraq War and have further honed their skills combatting ISIS and other Sunni militant groups. For more than a decade now, Iran has provided these groups with substantial training, weapons, and financial support, using them as proxies to undercut and marginalize groups that challenged Iran’s authority or that sought to strengthen the Iraqi state in a way that impeded Iranian influence. More recently, when ISIS undertook its offensive in June 2014, Qassem Suleimani, the head of Iran’s elite military unit, the Quds Force, personally organized these militias to confront ISIS and curb its expansion.

Iraqi Sunnis, some sections of both the Kurdish and Shia communities, as well as Western and regional policymakers, are increasingly alarmed that Iraq’s security environment is now dominated by various Shia militia groups that enjoy considerable autonomy from the Iraqi state and are either heavily backed or directly controlled by Iran.

Iraqi Shia fighters pose with an Islamic State flag which they pulled down on the front line in Jalawla, Diyala province, November 23, 2014. Reuters

Yet Iran’s influence over the Iraqi Shia community and Iraq more generally is, in reality, not as strong as it may first seem and can be rolled back. In fact, Iran’s past with Iraq’s Shia community is chequered. It is marred by historical political, cultural, and ideological differences that are not easy to bridge.

Why that is requires understanding the differences in the Shia communities in Iran and Iraq. For Iraq’s Shias (who are more recent converts to the faith than their counterparts in Iran), Shiism has traditionally had little political significance, with the religious establishment historically struggling to strengthen its bond with the Shia population amidst the dominance of other ideologies: communism, secular values, and the surge of Arab and Iraqi nationalism in the 1950s.

That started to change with the advent of the Islamic Dawa Party in 1958 and the decline of communism in the decades that followed. Although the Dawa Party was a Shia Islamic movement that worked closely with the Shia religious establishment, it was also a nationalistic socio-political actor. Generally, the Iraqi identity has played a historically central role to Shia political activism in Iraq. These differences lie at the heart of the historical confrontation between Shia Islamic actors in Iraq and Iran. For example, the relationship between Iran and Iraqi Shias is strained by the historic rivalry between the pre-eminent Shia seminaries in Qom, the main Iranian center of religious learning, and Najaf, the Iraqi one.

In 1965, a year after Iran’s Shah forced him into exile in Turkey, Ayatollah Ruhollah Khomeini, the architect and leader of the 1979 Iranian revolution, arrived in Najaf. Not wanting to rile his peers, Khomeini spent the first six years keeping a low profile—teaching religious jurisprudence and writing academic papers. But in 1970, he gave a series of lectures in which he put forward his doctrine, wilayat-i faqih, or “guardianship of the Islamic jurists,” which advocates expanding clerical authority to include executive power and authority over the state.

A woman prays next to a picture of Iran's late leader Ayatollah Ruhollah Khomeini, Tehran, June 2, 2007. Reuters

Eventually, Khomeini became increasingly vocal and belligerent, attacking his rivals who opposed his doctrine. In particular, relations deteriorated dramatically between Khomeini and Grand Ayatollah Abd al-Qasim al-Khoei, who became the leading Shia cleric in the Islamic world in 1970. Al-Khoei believed the religious establishment’s role should be confined to religious and spiritual matters, as opposed to engaging in the often tedious world of politics. These differences continue to this very day. Al-Khoei’s disciple and successor, Ayatollah Ali al-Sistani, vehemently rejects wilayat-i faqih, along with his peers in Najaf.

Iraq’s current ruling Shia parties, the Dawa Party and the Islamic Supreme Council of Iraq (ISCI), have also had a difficult relationship with Iran. The Dawa Party has historically resisted Iranian influence and control, even though Mohammad Baqir al-Sadr, its ideological founder, supported the rule of the jurist doctrine after the 1979 Iranian revolution. In 1982, ISCI, along with its armed wing, the Badr Brigade, was established in Iran during the Iran–Iraq war of the 1980s and the party supported Khomeini’s wilayat-i faqih doctrine. But its founding members were involved with the establishment of the Dawa Party in the late 1950s and 1960s and even had close relations with the Shah of Iran, Khomeini’s key rival. Both ISCI and Dawa’s fealty to Iran was most likely an alliance of convenience since they sought to topple Saddam Hussein’s Baath regime. Iran was also the only actor at the time that was willing to provide substantial support to these groups.

Furthermore, even though Dawa and ISCI backed Iran during the Iran–Iraq War, both groups consistently noted their desire to uphold the territorial integrity of their country. In their party publications, produced from the 1980s onward, they make territorial integrity and Iraqi nationalism key components of their vision for their country’s future. After the 2003 toppling of the Baath regime, the two parties began to distance themselves from Iran, much to Iran’s dismay.

Another sore spot in Iranian­–Iraqi Shia relations is the central role Iraq’s Shia community played in blocking Iran from exporting its revolution to Iraq during the Baath era. And during the Iran–Iraq war, Iraq’s Shias fought against Iran and many saw it as their patriotic duty. (Though admittedly, some may have fought Iran out of fear of the Baath regime.)

In all this, it is worth remembering that loyalties among the Shia militias often shift, even among fighters belonging to hardline Iranian proxy groups. Asaib al-Haq, for example, which has been accused of kidnapping three U.S. citizens in Iraq last month, is certainly reliant on Iran for funding, arms, and influence, but it is also comprised of a generation of Iraqis who grew up under both the repression of the Saddam regime and the poverty and hardship of the 1990s sanctions era. The political views and values of these mostly young, destitute Iraqi Shias were shaped considerably by the charismatic Mohammad Mohammad Sadeq al-Sadr, the founder of the nationalist Sadrist movement (from which Asaib al-Haq and other Shia militia groups emerged). Al-Sadr was a devout Iraqi nationalist who stressed the Shias’ Arab identity. He was also anti-Iran and saw Iran’s clerical rulers as his rivals. As a result, many militia members are not necessarily beholden to Iranian interests; indeed, the majority are more dedicated to protecting Iraq’s territorial integrity and their own future in Iraq than they are to fulfilling Iran’s geopolitical ambitions.

To be sure, even if Iran’s control over Iraqi Shias is limited, Iraq should still worry about the sectarian divisions being deepened by the fight against ISIS. Some of these militias groups have been implicated in war crimes against Sunnis and so naturally, many Sunnis regard them as an existential threat. These militias, however, cannot be eliminated as their social, political, and religious ideals overlap significantly with those of the Shia community. But to limit the dangers they pose, the Iraqi government must integrate these militias into Iraq’s political and security structures, as the United States did with the Badr Brigade during its occupation of Iraq by including them in the Iraqi armed forces.

If the militias reject such integration, which seems likely at this stage, their prominence can at least be reduced. They can be returned to the margins once again, just as they were after 2007 when the Iraqi state, with U.S. support, created a stronger and more organized Iraqi army. At that time, there was also widespread resentment toward the militias among both Sunnis and Shias because of their lawless behavior. To achieve this, the Iraqi state must be reinvigorated. That means emboldening the two major figures that have sought to stem the influence of both these militias and Iran: Prime Minister al-Abadi and Grand Ayatollah Sistani.

Al-Abadi is a moderate, and is more conciliatory and less divisive than his predecessors. This worries Iran and its proxies in Iraq. Sistani has historically constituted the greatest challenge to the Iranian regime’s legitimacy and he is losing his patience with Shia militia groups who operate autonomously and, increasingly, lawlessly. By working with these two actors and other moderate forces in Iraq, the Iraqi government might be able to push through key social and economic reforms and establish a serious and independent Iraqi army. That is Iraq’s best hope of rolling back the power of the militias and reversing Iran’s influence. In this respect, history is certainly on its side.