Iran has reportedly deployed two units of its Revolutionary Guards to Iraq in order to protect Baghdad and important Shiite shrines to the south from the growing ISIS-led insurgency. Given that tens of thousands died in a war between these two countries a few decades ago, this is a pretty stunning state of affairs.

Normally, it would be a cause for serious alarm in Washington, where there are already concerns about Iran’s growing influence over Nouri al-Maliki’s Shiite-dominated government. But it’s not as though the alternatives—a terrorist-run pseudostate straddling the Iraq-Syria border or a protracted civil war—look much better.

With the U.S. actively considering airstrikes against ISIS, Tehran and Washington awkwardly find themselves on the same side of this conflict, working to protect the Iraqi government from Sunni militants. The question is, is it possible for the two longtime foes to work together?

Citing a senior Iranian official, Reuters reports today that “Tehran is open to the possibility of working with the United States to support Baghdad” and that the prospect of cooperation “is being discussed internally among the Islamic Republic’s leadership.” The Obama administration hasn’t commented yet.

Relations between Iran and the U.S. have improved since Hassan Rouhani became president last year, but this hasn’t been a great couple of weeks. Nuclear talks have hit an impasse over the number of centrifuges Iran will be allowed to maintain for nuclear enrichment. It now seems unlikely that a deal will be reached by the July 20 deadline set by negotiators.

It seems like it should be possible to compartmentalize the nuclear issue while the two sides work together on another pressing priority. But the bigger obstacle may be Syria, where Iran has been one of the primary international backers of Bashar al-Assad’s government. Iran views ISIS as the inevitable consequence of American, Arab, and Turkish support for anti-Assad rebel groups. The U.S. view is that Assad’s brutal response to the moderate Syrian opposition led to the growth of radical opposition groups.

It’s hard to wrap one’s head around a situation where the U.S. and Iran are fighting as allies on one side of the porous Syrian-Iraq border and essentially fighting a proxy war on the other side, but all bets are off when it comes to Middle Eastern geopolitics at the moment.