Iraqi Prime Minister Haider al-Abadi has provoked a spat with Iran-backed groups in Iraq after he fired his national security advisor over his involvement in a rival political coalition.

In a statement released on Thursday evening, Abadi's office said he sacked Falih Alfayyadh - who is also chair of the paramilitary Hashd al-Shaabi, a group of militias known as the Popular Mobilisation Units (PMUs) - from all positions in government in order to "ensure that senior government officials are apolitical and protect the unity of Iraq".

He accused Alfayyadh of "having been implicated in partisan political matters which contravene the rules of neutrality which apply to members of the security and intelligence forces".

The larger PMUs are backed by Iran and are, for the most part, Shia, often being referred to in the Western press as "Shia militias".

Last year, Alfayyadh established the Ataa Movement, a political party that is a component of the Nasr coalition headed by Abadi, which came third in May's parliamentary elections.

However, recent reports suggested that Alfayyadh, who heads Ataa, had been involved in talks to ally with the Fatah Coalition, the PMU-backed alliance that came second in the elections and which is currently vying with Abadi and his allies to form a new government in Iraq.

Abadi's move to sack Alfayyadh was condemned by the Fatah Coalition, which accused the prime minister of pursuing his own agenda.

The group said the security chief's removal was “a serious sign and a new indicator that the outgoing prime minister is dealing with security services and other state bodies according to his personal interests.

“These decisions are illegal, according to the constitution, because Alfayyadh has responsibilities akin to that of a minister, which is a political post, similar to that of the Ministry of Defence and the interior,” they said.

Tensions had already been running high between Abadi and the PMUs after Alfayyadh's deputy, Abu Mahdi Al-Muhandis, ordered the PMUs to withdraw from "liberated" cities in Iraq - primarily Sunni areas - nominally at the request of local Sunni politicians.

Shortly after, Abadi, who as head of the army is also formally head of the PMUs, rescinded the order stating the decision could only be made by the commander-in-chief.

The PMUs were largely created in 2014 after a call to arms by leading Shia cleric Ali al-Sistani following the capture of Mosul by the Islamic State group.

Much of the organisation, however, is made up of groups backed by Iran, which has been accused of carrying out sectarian attacks on Sunnis.

The row takes place as different political alliances in Iraq vie to form a new government following the ratification of the 12 May parliamentary election.

Abadi has formed an alliance with Shia cleric Muqtada al-Sadr's Sairoun Alliance, which won the largest number of seats in the election. He has also partnered with the Al-Hikma movement of cleric Ammar al-Hakim and the mostly Sunni Al-Wataniya coalition, led by former prime minister Ayad Allawi. The group has pushed a non-sectarian stance and is regarded as critical of Iranian influence in Iraq.

Conversely, Fatah has formed an alliance with former prime minister Nouri al-Maliki's State of Law coalition and other smaller parties.

Kirk Sowell, publisher of the Inside Iraqi Politics newsletter, told Middle East Eye that Alfayyadh's sacking had been a long time coming and he had been just one of a number of members of Abadi's Nasr coalition to mull a split, allegedly over Abadi's domineering approach. Alfayyadh's split had, however, been the most "aggressive" after publicly meeting with Maliki on 17 August.

"While it is absurd for Abadi to accuse Alfayyadh of engaging in politics now, since he ran on Abadi's list in the election, Abadi is engaging in self-defence here," he said.

"He's been facing a revolt within Nasr, and Alfayyadh has been the most outward."

Iraq's parliament is set to convene on Monday - in the first session, MPs will elect a parliamentary speaker and two deputies. Parliament must then elect a new president by a two-thirds majority within 30 days of this first session.

The new president will then task the prime minister - nominated by the largest parliamentary bloc - with forming a new government.