Iran's Supreme Leader Ayatollah Ali Khamenei has warned Iraq's leader against weakening Shi'ite paramilitary groups and relying on the United States in the battle against the Islamic State (IS) extremist group..

At a meeting with Iraqi Prime Minister Haidar al-Abadi in Tehran, Khamenei said the Shi'ite militias were the main forces pushing back against the Sunni extremist group in Iraq, and Baghdad should not trust the United States, Iranian state media reported.

The Shi'ite militias, known as the Popular Mobilization Forces, helped Baghdad defend the country against IS when Iraqi military and police divisions deserted en masse in 2014.

Since then, the Iran-backed militias, estimated to comprise more than 60,000 fighters, have been engaged in the battle to recapture swathes of northern and western Iraq from IS.

But Sunnis in areas freed from IS control have accused the Shi'ite militias of looting, abductions, and murder.

Some Arab leaders in northern Iraq have asked Baghdad to dissolve the Shi'ite militias or expel them from their Sunni-majority provinces -- moves that drew objections from Iran's leader.

"Daesh is retreating from Iraq and that is thanks to the government’s trust in these young devoted forces," Khamenei said, using an Arabic acronym for IS.

"The Americans are against Popular Forces because they want Iraq to lose its main source of strength," he said.

Khamenei accused the United States and its ally Saudi Arabia of creating IS and said he opposed the presence of U.S. forces in Iraq.

"We should remain vigilant of the Americans and not trust them. The Americans and their followers are against Iraq's independence, unity, and identity," Khamenei said.

Iranian President Hassan Rohani, who also met with Abadi on June 20, joined Khamenei in claiming credit for recent gains by U.S.-backed Iraqi forces in recapturing IS's northern stronghold of Mosul.

"The liberation of Mosul is the symbol of the end of terrorism and a victory for Iran, Iraq, Syria, and all the countries of the region that are fighting against terrorism," Rohani said.

The Iranian leaders' comments highlight the balancing act faced by Abadi as he strives to hold together a coalition of forces fighting IS in Iraq, including the Iraqi government's own soldiers, the Shi'ite militias as well as Sunni tribal forces and Kurdish Peshmerga forces, all backed by U.S. trainers and special forces.

While Iran said its forces deserved credit for gains made against IS, the United States and its anti-IS coalition of Western forces have also claimed credit for helping Iraqi ground forces recapture Ramadi and other cities liberated from IS in the past two years, as well as for the recent gains in Mosul.

Abadi faces a balancing act not only at home but in the broader Persian Gulf region. His meeting with Iran's leaders came one day after a visit to Saudi Arabia, Iran's regional rival, in what he said was a tour aimed at promoting reconciliation between the region's Sunnis and Shi'a.

Iraq lies on the fault-line between Shi'ite Iran and the mostly Sunni Arab world.

Abadi belongs to the Dawa party, a Shi'ite group with close ties to Iran. But analysts say he has managed relations with Iraq's Sunni minority better than his predecessor, Nuri al-Maliki, and also improved Baghdad's ties with Saudi Arabia.

Khamenei told Abadi that Iran was opposed to the referendum on independence scheduled by leaders of Iraq's autonomous Kurdish region for September, saying such a separatist move threatens Baghdad's sovereignty and territorial integrity.

Iran has its own Kurdish minority in the west of the country.

With reporting by AP, AFP, and Reuters