Iran and the United States share a common enemy in the Islamic State militant group, but a deep-seated lack of trust has so far kept the longtime foes from publicly joining hands in a coalition to defeat the extremists.

Their inability to work together complicates efforts to beat back the extremists that both Washington and Tehran see as a threat, and has left Iraq's new government — which considers both countries allies — scratching its head as it tries to tackle the most serious threat to its stability since American troops left in 2011.

Iraq's new prime minister, Haider al-Abadi, made his frustration clear in a recent interview with The Associated Press, saying U.S. pressure to keep Iran away from talks in Paris aimed at combatting the militant threat had left him "in a very difficult position."

"I actually find it puzzling that we hold a conference in Paris to help Iraq and to fight terrorism and ... the biggest neighbor of Iraq — Iran — is excluded," he said.

Iran is convinced the United States wants to use the fight against the Islamic State group as a pretext to strike Tehran's ally, Syrian President Bashar Assad. Rejecting any cooperation with Assad, Washington is planning airstrikes against the Islamic State group in Syria and says it will beef up Syrian rebels to fill the void as it drives out the extremists.

Iranian officials are even skeptical the U.S. really opposes the Islamic State group, since it is fighting Assad, whom the U.S. wants removed from power. On Tuesday, the top commander of Iran's Revolutionary Guard dismissed the anti-Islamic State group coalition as "a show."

"There is not much hope in this coalition since they've set it up for their own objectives," Gen. Mohammad Ali Jafari said. "We have serious doubts that this coalition seeks to destroy the Islamic State."

Iran's foreign minister, Mohammad Javad Zarif, also has ruled out cooperating with the United States in helping Iraq fight Islamic State militants. Speaking at the Council on Foreign Relations on Wednesday in New York, he expressed doubts about Washington's willingness and ability to fight the group "across the board."

The United States is wary of furthering Iranian influence in Iraq by bringing it into the fight. It also does not want to alienate key Sunni countries it is trying to rally behind its coalition, like Saudi Arabia, which is Iran's top rival in the region.

Nevertheless, Iran has already been closely involved in the fight. Iranian-backed Iraqi Shiite militias have been leading some of the fighting against the group on the ground. Iranian Revolutionary Guard advisers in Iraq have helped coordinate between militias and the Iraqi military against the extremists, according to Iraqi officials.

Iran has publicly confirmed that it has provided military advice to Iraqis including Kurds to fight the Islamic State militants but has denied sending forces or shipping weapons.

Zarif says Iran's assistance — without any troops — helped Iraq prevent the Islamic State group from taking over Baghdad and the Kurdish capital Irbil.

Washington and Tehran have been in back-room contacts about cooperation for weeks, and leaders of the two countries — who talked a year ago — are arriving next week for the annual ministerial meeting of the U.N. General Assembly. Within Iran's diplomatic circles, some moderate voices supported an alliance with the U.S. against the militants.

But on Monday, Iran's supreme leader, Ayatollah Ali Khamenei, who has the final say on all state matters, decisively ruled out an alliance. He said Iran had rejected an invitation by U.S. Secretary of State John Kerry to discuss cooperation.

Khamenei said the U.S. was "seeking a pretext" for military intervention in Iraq and Syria and warned that if the Americans go ahead with it "they will suffer the same problems they faced in Iraq in the past 10 years."

Speaking later the same day, Kerry did not address whether the U.S. had made any such invitation. He said that while the U.S. has ruled out any military coordination with Iran, it is open to communications "to find out if they will come on board, or under what circumstances, or whether there is the possibility of a change."

Despite their long decades of enmity, Iran and the United States have been united by a common enemy before: Afghanistan's Taliban. When the U.S. invaded Afghanistan in 2001, Iran coordinated with it, especially on operations in the western part of the country near its border. The cooperation ended badly, however, when then-President George W. Bush branded Iran part of an "axis of evil," infuriating Tehran.

Saeed Leilaz, an Iranian political analyst, says Iran has not completely shut the door to talks with the U.S. on the crisis.

"Nowadays, Iranian and American officials privately talk for 10 hours a day. Definitely, they also talk about the Islamic State group," Leilaz said. But Iran wants the U.S. to clarify its intentions in the region before any cooperation, he said.

But for the moment, Tehran and Washington are likely to operate separately against the group.

Iran's deputy foreign minister, Amir Abdollahian, said his country won't wait for a coalition to act against extremists. He said the best way to fight the group is "to assist Iraqi and Syrian governments, which are actively involved in the fight against terrorism."