It was a tense confrontation between two forces supposed to be on the same side in Iraq.

First, heavily armed police, led by the interior minister, waded into a Shiite militia base south of Baghdad and arrested its deputy commander, accused of organizing attacks on Sunni mosques. They loaded the man, Ali Reda, into an armored SUV.

Then militia reinforcements descended, surrounded the police and demanded Reda be freed. Weapons were drawn. The minister, Mohammed al-Ghabban, the highest figure in Iraq's police force, frantically called Baghdad from inside his SUV.

In the end, al-Ghabban surrendered his prisoner and left empty-handed, angry and humiliated.

The standoff in mid-January, described to The Associated Press by six different officials and militia leaders, was a stark example of the power that Shiite militias have accrued in Iraq and their boldness in wielding it.

These militias, many of them backed by Iran, mobilized in 2014 to fight Sunni extremists from the Islamic State group. However, they are now showing no intention of standing down after the battle, demanding instead to be a major force shaping Iraq. That prospect worries not only Iraq's Sunni minority but also officials in the military and the Shiite-led government, who fear the militias will dominate Iraq the way the Revolutionary Guard does Iran and the guerrilla group Hezbollah does Lebanon.

Two top generals warned that the army could eventually come to blows with the militias, known collectively as the "Hashd," Arabic for "mobilization."

"They (the militias) have now infiltrated the government and are meddling in politics," said Ali Omran, commander of the army's 5th Infantry Division and a veteran of numerous battles against IS. "I told the Hashd people that one day I and my men may fight them."

The more than 50 Shiite militias in Iraq have between 60,000 and 140,000 fighters, according to estimates from the government and the Hashd itself. They are backed by tanks and weapons, and have their own intelligence agency, operations rooms and court of law.

The larger militias, like Asaib Ahl al-Haq, the Hezbollah Brigades, Badr and the Peace Brigades, have been in place since soon after the 2003 ouster of Saddam Hussein. They are linked to political parties, effectively forming armed branches for politicians.

But the ranks of the militias swelled dramatically after IS overran nearly a third of Iraq in the summer of 2014 and Grand Ayatollah Ali al-Sistani, Iraq's top Shiite cleric, called on able-bodied males to fight IS. At the time, tens of thousands turned out.

Those same militias now want to remain a permanent, independent armed force and are resisting attempts to integrate them into the military or police, the AP found from interviews with more than 15 government officials, army generals and militia leaders and visits to Tikrit and Samarra, Sunni-majority areas where the militias now hold power. The militias insist they have earned a special status, pointing to the 5,000 militiamen killed and 16,000 wounded fighting IS.

"Those who sacrificed more are entitled to more," said Hamed al-Jazaeery, head of the al-Khorasani Brigades militia. "What is written with blood cannot be removed. It is not ink on paper."

Al-Jazaeery wears the black turban of a cleric and the camouflage fatigues of a fighter. The walls of his office are adorned with photos of the leader of Iran's Islamic Revolution, Ayatollah Ruhollah Khomeini, and its current supreme leader Ayatollah Ali Khamenei. Other photos show al-Jazaeery posing with Iranian Gen. Qassem Suleimani, the powerful Revolutionary Guard figure who helped organize the Iraqi militias against IS.

"We want to be a third power in Iraq," alongside the army and police, al-Jazaeery said. "Why can't the Hashd be like the Revolutionary Guard in Iran?"

The model of the Revolutionary Guard, often cited by militia leaders, would be a dramatic change for Iraq's militias. In Iran, the Guard is an elite force independent of — and better armed than — the military, tasked with "protecting" the Shiite cleric-led power structure. It is effectively a state within a state, rivaling the political strength of Iran's supreme leader.

Sunnis fear such militia power would enforce Shiite domination of Iraq. Sunnis already accuse militias of targeting them with abuses. Hundreds of green and red Shiite banners and images of imams — historic religious leaders revered by the Shiites — are posted all over Sunni areas under militia control north and east of Baghdad, in a blatant challenge to sectarian sensitivities.

The militias call themselves "holy" or "glorious," and often talk of their battle as a fight for Shiism rather than Iraq. They give Shiite names to major offensives, only for the government to ban their use.

"I joined the Hashd for the imams, not for the government," said one militiaman, Mohammed al-Azghar, in the central city of Samarra.

The official agency created to oversee the fighters, the Popular Mobilization Commission, has instead become the militias' political lever in the machinery of power. The government now funds the militias, but some of them refuse to even give officials the names of their fighters, citing security concerns.

"People fear and trust us more than they fear and trust the government," boasted Ahmed al-Assady, a Shiite lawmaker and spokesman for the Mobilization Commission. "They fear us because we act, not just talk."

Advisers from Iran's Revolutionary Guard and Lebanon's Hezbollah have helped Iraq's militias in the battle against IS. Billboards around Baghdad announce the "martyrdom" of fighters, alongside images of Iran's Khamenei and Khomeini and Hezbollah leader Hassan Nasrallah. Militia TV channels and newspapers also accuse the government of corruption and cast the militias as the true protectors of Iraqis.

In Tikrit, Saddam Hussein's hometown north of Baghdad, the extent of the militias' prestige is on display: The headquarters of a senior militiaman, Jassim al-Husseini, is located at one of the late dictator's opulent palaces along the Tigris River.

The chain-smoking al-Husseini wears a military brown jacket and walks with a cane because of a leg injury sustained while fighting IS last year. He confidently spoke of the flaws of Iraq's government and said the militias cannot be integrated into its security forces.

"Integrating us in the security forces and the military is not an idea that will help build our nation," he said.

Now the militias demand to participate in a long-expected offensive to retake largely Sunni Mosul, Iraq's second-largest city and the main stronghold of IS rule in Iraq — something the military and armed Sunni groups oppose.

"The Hashd will take part in the battle to liberate Mosul no matter what," said senior Shiite politician Hadi al-Amry, who is also commander of the Iranian-backed Badr militia. "No one can stop us from entering Mosul."

In Samarra, Sunnis say they already experience what is feared could happen if the militias enter Mosul. The city has a Sunni majority but is home to one of the most revered Shiite shrines, blown up by al-Qaida 10 years ago. In 2014, Shiite militias successfully prevented IS from taking Samarra and have kept their grip on the city since.

Local dignitaries and officials air a flood of grievances blamed on militias, including killings of Sunnis, takeovers of schools and the forcing of Sunnis to sell property in the prime real estate area close to the shrine. To the thud of artillery shelling in the distance, the city council's deputy chairman, Muzher Fleih, said 650 Sunnis have disappeared, believed abducted and killed by the militias. Among them was his brother, who disappeared last year and was found dead soon after.

"The city is oppressed," he said.

Militia leaders insist any abuses are isolated incidents. "We are not angels," said al-Assady, the Mobilization spokesman. "It is only natural that we make mistakes."

Some in the government and military are beginning to see the militias as a danger to the state itself. In a sign of wariness over the militias' autonomy, Shiite Prime Minister Haidar al-Abadi charged recently that government funds to the Hashd were being mismanaged. One of his close aides told the AP that the comments were directed at Abu Mahdi al-Mohandes, the Hashd's most powerful figure, who is wanted by the United States in connection with the 1983 bombing of the American and French embassies in Kuwait.

There has also been friction with the military. Last month, militiamen refused orders to vacate a building in a military base north of Baghdad, and the army sent troops to take it over. They found the militiamen ready for a fight, with snipers stationed on the roof and in sandbagged positions around it. The dispute was resolved when a substitute building was found for the militiamen.

Since its 2014 collapse, the military has been slowly recovering. But Gen. Abdul-Wahab al-Saadi, deputy commander of the army's elite counterterrorism force, said the militias don't want the military to regain its strength.

"They may be tempted to take on the army if they don't have their way," he said.