It’s still possible that the United States will use airstrikes against the Islamic State of Iraq and Syria (ISIS), the Al Qaeda offshoot whose surprise seizure of Mosul and a string of other cities in Iraq has left devastation, chaos and mass executions in its wake. But since President Obama has said, pretty much explicitly, that he won’t defend the government of Prime Minister Nouri al-Maliki unless Maliki reconciles with the Sunnis and Kurds and becomes more inclusive, and since Maliki isn’t likely to do so, there doesn’t seem to be much of an opening for the United States to act militarily in his defense.

In any case, in the short term Maliki probably doesn’t need Washington’s help. (Not that US airstrikes would help: they’d cause many civilian casualties, inflame the Sunnis against the United States and embolden Maliki to continue his sectarian course.) Maliki can count on getting whatever help he needs from Iran, which is next door, has a strong interest in crushing the Sunni revolt in both Iraq and Syria and has ready-made militias in Iraq who are already mobilizing to defend Baghdad and Shiite shrines in Samarra, Najaf and Karbala. Many of them are religious fanatics, equal in their zeal to the Sunni fanatics of ISIS, and the first signs of sectarian, tit-for-tat massacres are already emerging. As in 2006, things in Iraq will probably get very ugly, very fast.

The central irony of the joint Iraq-Syria civil war—and it has, indeed, become a single war now—is that the United States is on both sides of the war. In Iraq, the United States supports Maliki. In Syria, the United States backs the Islamist rebels who are battling President Bashar al-Assad. (Iran shows no such signs of schizophrenia, and it supports the governments in both Baghdad and Damascus.) And while it’s wrong to blame Obama for leaving Iraq too soon, in 2011—that schedule was set by President Bush in 2008, and Obama tried to extend the deadline but failed—it’s certainly legitimate to blame Obama’s support for the anti-Assad rebels for helping to strengthen and intensify ISIS military force in both countries.

So the first thing that Obama could do to blunt the ISIS offensive in Iraq is to stop American support for the Syrian rebels. The Obama administration hasn’t figured it out quite yet, but Assad has already won that war, and the rebels have lost. Even so, ISIS and its radical, Al Qaeda–linked allies control parts of Syria’s north and east, and by ending American (and Saudi) support for the anti-Assad forces, it might free up enough Syrian troops to head north and east and crush ISIS et al. Meanwhile, the United States can try to work with Iran, Russia and Saudi Arabia to negotiate a political deal in Syria.

If any deal in Syria is to happen, and the same goes for Iraq, the essential element is a détente between Iran and Saudi Arabia. As I’ve written before, the Syria-Iraq civil war is a proxy war pitting Iran and its Shiite-Alawite coalition, including Hezbollah, against Saudi Arabia and its Sunni bloc, including Iraq’s Sunni tribal militia, remnants of the Iraqi Baath party and Syria’s majority Sunni population. Obviously, Maliki’s intransigent refusal to deal fairly with Iraq’s Sunnis and Assad’s dictatorial refusal to accommodate Syria’s own Sunni-led opposition both generates radicalism among the region’s Sunnis and creates recruits for extremists such as ISIS and the Al Nusra Front in Syria.

How would a détente help? Iran could twist Assad’s arm to force him, newly re-elected, to negotiate a government of national unity in Syria, bringing in some of the opposition forces (though not the terrorists). And Saudi Arabia could help isolate the terrorists, such as ISIS and Al Nusra, along with some of the egregious hotheads among the Qatar-backed Syrian militants, and persuade them to sit down with Assad at a Geneva-style peace conference. It could take years for that to work, but the first step could be a cease-fire, and that could happen a lot more quickly. So that’s Syria.

In Iraq, Maliki is probably not capable of leading a peaceful transition. He’s a hated figure. But Iran, with vast influence among the Shiites, could find another candidate who’d agree to succeed him and who’d reach out to Iraq’s Sunni tribal militias. Iran doesn’t want to “own” Iraq, it just wants an Iraq that doesn’t threaten Iran à la Saddam, in which the Sunnis are contained and the Kurds neutralized. As for Saudi Arabia and Turkey, they’d have to pave the way for the Sunnis in Iraq to accept a new Iraqi prime minister, who’d give them a proper share of Iraq’s oil wealth and adequate prestige and recognition. That, too, could take several years, and many thousands of Iraqis are going to die before ISIS is exhausted and is destroyed.

Weirdly enough, the United States is talking to Iran about some sort of cooperation in Iraq. (Not so in Syria: there, the United States is escalating its military opposition to the pro-Iran government in Damascus.) Since 2003, Iran has held the high cards in Iraq, even during the US occupation, by virtue of its close ties to Maliki’s Al Dawa party, to Ahmed Chalabi, to the Supreme Council for the Islamic Revolution in Iraq (SCIRI), and other anti-Saddam Shiite groups. Now Iran has close ties to powerful Shiite militias in Iraq, including the Badr Organization, which was founded by Iran’s Islamic Revolutionary Guard Corps (IRGC) as SCIRI’s own private army. Lately, the head of the IRGC’s Al Quds force has been in Baghdad, working out anti-ISIS strategy with Maliki.