To save Iraq from Sunni extremists, Iran is mobilising its allies in Iraq and promoting collaboration between Iraq's government and Syria. Washington, meanwhile, has dispatched military advisors to Baghdad. On their own, these efforts are valiant. But without coordination, they won't be fruitful.
Iraq was until recently a battleground between Iran and the US. A string of American military commanders battled Gen Qassim Suleimani, head of foreign operations for Iran's Islamic Revolutionary Guards, for influence. At the height of the American occupation, Iran's handful of men in Iraq wielded more power than the 150,000 American forces stationed there.
Despite their largely adversarial past, the two countries can now save Iraq if they act together. History has shown that Iran and the United States are capable of pulling Iraq away from the abyss. The civil war that plagued the country from 2006 to 2008 offers lessons in how to stop the current bloodshed.
Back then, Iran was the only country that could pressure Syria to block the Sunni jihadist pipeline, while reining in the Shiite death squads that were bent on ridding the Iraqi capital of Sunnis. And the US, as an occupying power, was able to approach and co-opt rebellious Sunni tribes. Without coordination, these efforts would have failed.
The head of the Islamic Supreme Council of Iraq at the time, Abdul Aziz al-Hakim, and President Jalal Talabani struggled to get Washington and Tehran to work together. Despite the collapse of the nuclear negotiations that were then taking place between Iran and the European Union, the US and Iran managed to cooperate.
The first crucial step toward ending the violence was tacit American-Iranian support for Nuri Kamal al-Maliki. After becoming prime minister, Maliki returned the favour. Within a year of his inauguration, in the summer of 2007, Iranian and American diplomats met in his office - the first senior-level meeting between the two adversaries in almost 30 years.
Hakim and Talabani are no longer on the political stage. But Maliki is. Despite his authoritarian tendencies and his failure to integrate Sunnis into the political process, he remains the least unpopular Iraqi politician today. His success in the April 30 election is proof of that.
And Iran and America still agree on keeping Maliki in power - largely for lack of better options. Despite rumblings in Congress, Secretary of Defense Chuck Hagel has stated that "the question of whether Maliki should step down is an internal Iraqi matter." And President Obama didn't hesitate to send military personnel back into Iraq.
The outcome of the Sunni offensive is predictable. ISIS will fail in holding and governing captured territory because Iraqi Sunnis are unwilling to conform to the visions of state and society espoused by ISIS. America's earlier success in turning some Iraqi Sunnis against militant extremists is proof, and Maliki knows this. While Sunni political integration is crucial, violence should not be rewarded with concessions. ISIS and its allies must be repelled from major urban centres and border crossings before any talks with pragmatic militants can occur.
Iraq's Sunnis must either accept the realities of the country's new political order, which is dominated by Shiites and Kurds, or condemn themselves to the perennial instability and violence brought on by the extremists in their ranks and the foreign fighters who have joined them.
The Kurds also face difficult choices. For years they have lived in the twilight between independence and federalism. The US and Iran must impress upon Kurdish leaders that using the current turmoil to gain concessions from Baghdad on issues such as independent oil exports and the future of the disputed city of Kirkuk will backfire. Washington is loath to take sides between Erbil and Baghdad. And if it does, it is unlikely to act to antagonise Maliki. Neither will Tehran.
Iran and America must also manage external spoilers. Saudi Arabia has long seemed unwilling to accept the realities of the new Iraq. But the kingdom can be flexible when intransigence seems self-defeating. Washington must impress upon the Saudis that the fire of extremism will inevitably enter the heart of the Arabian Peninsula unless action is taken to halt support for militancy. Indeed, in a twist of calculations, America may actually now share Iran's interest in seeing ISIS's other major foe, the Syrian regime of Bashar al-Assad, go after Sunni extremists. Assad's warplanes are now bombing militants on the Iraqi border, which they were not doing last week.
Iran and the US should also seek to divide ISIS. If the group is only confronted in Iraq, it will withdraw to Syria to return another day. The US can't and shouldn't act as Iraq's air force. But American military and technological prowess - in the form of sales of drones, helicopters and fighter jets - should be combined with Iranian and Syrian intelligence to prevent the movement of extremists.
Finally, Iran and the US must boost the Iraqi Army's strength and prevent the rise of militias. Maliki claims that thousands of volunteers who have signed up to fight ISIS will be the core of the next Iraqi Army, but he needs enough political, military and intelligence help from America and Iran so that he won't have to rely on irregular forces. Any shift away from the army and toward the militias would be profound and unpredictable.
Despite their differences, Tehran and Washington both need a stable Iraq. If not for the good of Iraqis, they should cooperate for the sake of their own interests.