Their 35-year-old mutual enmity notwithstanding, the United States and Iran have cooperated against a common jihadist enemy in the past, such as when they worked together to topple the Taliban regime following the 9/11 attacks. Relations quickly soured again when U.S. President George W. Bush's administration declared the Islamic republic a part of the "axis of evil" and when controversy over Tehran's alleged nuclear weapons program broke out in 2002. However, these tensions did not prevent the two sides from cooperating again in the U.S. move to effect regime change in Iraq in 2003.

For Iran, Washington's decision to topple Iraq's Baathist government was a godsend; it turned Tehran's biggest national security threat into a major geopolitical opportunity. The Iranians did everything they could to facilitate the ouster of the government led by Iraqi President Saddam Hussein. In these efforts, the United States' Iraqi partners — for instance, the Shia and Kurds — had long been proxies of Iran. These two communities, which had been disenfranchised for decades under a Sunni-dominated order, received support from Washington and Tehran, first to topple the old order and then to form a Shia-dominated state in which the Kurds had considerable autonomy.

Throughout the nearly nine-year U.S. military presence in Iraq, Iran and the United States engaged in a long, complex game of cooperation and competition. At one point, back-channel talks were insufficient, and Tehran and Washington engaged in direct public talks about the future of Iraq's post-Baathist republic. Now, as the state jointly fashioned by the Americans and Iranians faces its greatest challenge since the end of the Sunni insurgency in 2007, it is only natural that the two powers join forces once again to meet the common threat. Tehran and Washington's concerns about the Islamic State transcend Iraq's borders and include common interests elsewhere in the region. The ongoing process of rapprochement facilitates such joint action. Thus, the geopolitical context for U.S.-Iranian cooperation is quite favorable.

The principal negotiators who engaged in back-channel diplomacy in Oman after the Iraqi army collapsed in the face of the Islamic State were Hossein Amir-Abdollahian, Iran's deputy foreign minister for Arab and African affairs, and Jake Sullivan, adviser to U.S. Vice President Joe Biden. The United States and Iran worked behind the scenes to replace outgoing Iraqi Prime Minister Nouri al-Maliki, whom Washington and Tehran hold responsible for the political crisis in Iraq. Tehran and Washington have also been working together to ease tensions between the Shia and Sunnis, as well as between Baghdad and Arbil. That said, Washington and Tehran know that managing political feuds among Iraq's three principal ethno-sectarian groups, while necessary, will not be sufficient. The Islamic State poses a military threat to Iraq, and neither the Iraqi military nor the Kurdish peshmerga forces are in a position to fight back. Effective operations against the Islamic State will require Washington and Tehran to support their common allies in Iraq and engage in direct military action.

Although they are working together, Washington and Tehran cannot be seen as openly cooperating. The administrations of U.S. President Barack Obama and Iranian President Hassan Rouhani already face considerable domestic opposition to their difficult negotiations over the nuclear issue, but the problem goes beyond that opposition. There is genuine mistrust between the two countries that limits the extent to which they can cooperate against the Islamic State — especially in the areas of military and intelligence. Neither side wants to reveal its assets or processes to the other.

This mistrust makes it very difficult, for example, for the Quds Force — the overseas arm of Iran's Islamic Revolutionary Guard Corps — and the Ministry of Intelligence and Security to work comfortably with the U.S. military's Central Command and the CIA. This is why the two sides are likely to be coordinating their respective moves instead of working closely together. In fact, Stratfor has learned that Washington and Tehran agreed on the limited force the Quds Force has deployed in Iraq's Diyala province to fight alongside Kurdish peshmerga forces against the Islamic State.

While the United States deployed several hundred military advisers to Iraq after Mosul fell to the Islamic State, the Quds Force has long maintained a presence in Iraq — one that it has been reinforcing since the rise of the Islamic State. Because U.S. and Iranian military personnel are working with the same set of Iraqi actors, the two sides occasionally step on each other's toes. Enhancing the Iraqis' capacity to face the threat requires that U.S. and Iranian personnel accommodate each other to avoid such a situation.

Though the Iranians have been running a limited number of air sorties in Iraq, the bulk of Tehran's efforts will be ground-based, whether they involve actual troops engaged in combat and supporting Iraqi forces or the mobilization of militias. The United States will largely be engaged in air operations, given the domestic aversion to sending in ground troops. This works well for both sides; the Iranians do not have the air assets that the Americans do, and having the Iranians focus on ground operations serves the United States' interests.

This does not mean that either side will get comfortable with this working relationship. However, the situation in Iraq is driving the United States and Iran toward cooperation. There are many reasons why this is likely to remain a tactical arrangement, especially when it comes time to confront the Islamic State in Syria, where the two countries' interests do not align.