When I was in Tehran last December, I called on Ibrahim Asgharzadeh, who had been the student ringleader of the 1979 U.S. Embassy takeover and hostage crisis. His hair is white these days, and coiffed, and he has the girth and the slouch of his years. He still speaks with the same intensity, but his cause now is the need for coöperation between Iran and the United States.

“We have common ground in fighting terrorism,” he told me, sitting on an elegant settee in his apartment. “I would like to spend all my energy to heal this wound”—he meant the legacy of the hostage crisis—so that both countries might confront the “cancerous tumor” of Sunni extremism in the Middle East. “Shiites get on better with the West,” he said. “Sunni leaders are more radical than Shiites.”

I’d come to Iran to report on the new nuclear diplomacy between Tehran and Washington. But Iranians often brought up a different subject. The Iranian Foreign Minister, Mohammad Javad Zarif, warned me about a frightening group that had originated in Iraq. Little noticed by the rest of the world, it was operating from Syrian bases, had a cultlike attraction, and was clearly trying to get back into Iraq.

“The so-called Islamic State of Iraq and the Levant”—ISIS—“is a group that is killing more people today in Baghdad than they are killing in Damascus,” he told me. “These are very, very dangerous groups of people, and we need to take corrective measures in order to preclude their expansion in other parts of the region. And, also, we need to work together in order to contain the spread of sectarian tension and violence in the region.” He went on: “It is in the interest of all players to help facilitate a resolution to the Syrian crisis, and Iran is simply one of them.”

A month later, the Iranians were disinvited from the international conference in Switzerland, attended by nearly forty countries, on how to end the Syrian civil war. Tehran believed that it could help broker a new government, as it had for Afghanistan after the Taliban’s ouster, in 2001. Iran had a four-point plan, which included a ceasefire and democratic elections that would be monitored by the United Nations but would allow President Bashar al-Assad to campaign to keep his office. Other participants balked. The reasons reflected regional rivalries and sectarian tensions, and, more fundamentally, Iran’s designation as a state sponsor of terrorism by the State Department and its longstanding military ties to Assad. The Islamic Republic had credibility problems.

The diplomatic initiative, which brought together representatives of the Syrian government and Western-backed rebels, quickly fizzled, and ISIS gained ground against both the government and the moderate rebels. By June, black-hooded gunmen were racing their pickups across the Syrian border back into Iraq.

To salvage Iraq, another peace effort was convened in Paris earlier this week, with representatives from more than two dozen countries. Again, Iran was excluded, owing mainly to pressure from Saudi Arabia and the United Arab Emirates, the two Sunni sheikhdoms that deeply distrust Iran’s Shiite theocracy. Iran lashed back, arguing that it’s now stuck mopping up a crisis created by the mistakes and miscalculations of others. In New York this week, before the opening of the United Nations General Assembly, Zarif led the charge. “The United States responded to this menace long after it started,” he said at the Council on Foreign Relations. “Iran was not invited to Paris, which I would call a Coalition of Repenters, because most participants in that meeting, in one form or another, provided support to ISIS in the course of its creation and upbringing and expansion—actually, at the end of the day, creating a Frankenstein that came to haunt its creators.”

The United States shared the blame, he said, because Iraq had not become a “terrorism magnet” until after the American intervention, in 2003. The thousands of foreign recruits now swelling the Islamic State’s ranks didn’t come from Iran, he noted, but from the countries “sitting around the table in Paris.”

Yet, after a decade of trying to drive each other out of Iraq, the United States and Iran find themselves on the same side. Last month, Washington and Tehran separately came to the military rescue of the beleaguered Iraqi government after it lost a third of its territory, as ISIS threatened both Baghdad and the Kurdish capital of Erbil. U.S. warplanes began air strikes on August 8th. Iran flew in planeloads of equipment and military advisers to Kurdish peshmerga fighters and Shiite militias.

Other countries in the new U.S.-led coalition will play their roles—French warplanes launched their first air strikes on ISIS earlier today—but the fact that Washington and Tehran have a shared interest in the outcome may prove just as decisive. Iran’s Supreme Leader, Ayatollah Ali Khamenei, disclosed this week that Washington had made at least three recent approaches to Tehran about Iraq—through Secretary of State John Kerry, the U.S. Ambassador in Baghdad, and the top U.S. negotiator at the Iran nuclear talks.

“I said no, because they have dirty hands,” Khamenei said on his official Web site. Washington, he declared, wants a “pretext to do in Iraq and Syria what it already does in Pakistan—bomb anywhere without authorization.” Zarif told me. “We have serious doubts about the willingness and ability of the United States to engage in a serious reaction to this menace across the board.” He meant ISIS. “This is a very mobile organization,” he said. “It’s not stationary so you can [just] attack it in Iraq.”

For all the rhetoric—perhaps for domestic consumption—Tehran does not oppose a virtual partnership with Washington on Iraq. “We were on the side of the Iraqi people, the Iraqi government, and the Kurdish government to actually help them fight ISIS,” Zarif said at the Council of Foreign Relations. “If the United States does the same, then it is up to the Iraqi government to coördinate how it wants to coördinate.”

But Zarif’s main pitch in New York—which is likely to be a theme of President Rouhani’s appearance at the United Nations next week—is that any campaign to eradicate the ISIS forces can’t rely on mere aerial bombardment. He told the Council, “We also need to stop providing them with those recruiting grounds, with those fertile possibilities of resentment, of disenfranchisement that can allow them to attract the youth in so many parts of the world, from the Middle East to Europe and the United States.” Next time, it was clear, Iran doesn’t want to be excluded from the process.

And maybe it won’t be. Kerry hinted as much this afternoon, when he chaired a Security Council meeting on Iraq. The coalition required to eliminate ISIS, he said, “is not only, or even primarily, military in nature.” He went on, “It must be comprehensive, and include close collaboration across multiple lines of effort. It’s about taking out an entire network, decimating and discrediting a militant cult masquerading as a religious movement. There is a role for nearly every country in the world to play. Including Iran.”

Update: On Sunday, September 21st, Secretary Kerry and Foreign Minister Zarif met for an hour at the Waldorf-Astoria Hotel in New York. They discussed the continuing negotiations over Iran’s nuclear program and the threat posed by ISIS, and, according to a senior State Department official, “agreed to meet further as needed while in New York this week.”