The Iranian President Hassan Rouhani at the United Nations on September 25th. Photograph by Spencer Platt / Getty

Iran’s President, Hassan Rouhani, did not shake hands with Barack Obama at the United Nations this week, a year after their celebrated cell-phone chat. The two men didn’t even pass each other in the hallway. But Rouhani did give a quiet dinner at his hotel on Tuesday for twenty former American officials—including a secretary of state, three national-security advisers, and a chairman of the Joint Chiefs of Staff—from all six Administrations since the 1979 revolution.

He and his guests sat at four tables arranged in a rectangle, around a four-foot-tall bouquet of showy flowers, including pastel gladioli, an Iranian favorite. The private event may have been more important in shaping the thinking of Washington’s policy community than Rouhani’s speech to the General Assembly yesterday.

It’s crunch time for diplomacy on Iran’s controversial nuclear program, with not much moving lately and the November 24th deadline looming. Tehran and Washington have also, suddenly, found themselves with common cause in confronting the Islamic State in Iraq and al-Sham. The ISIS threat was Rouhani’s primary focus during his week of intensive public diplomacy in New York. It overshadowed the nuclear issue—and redefined Tehran’s motive for wanting a deal.

“I deeply regret to say that terrorism has become globalized—from New York to Mosul, from Damascus to Baghdad, from the Easternmost to the Westernmost parts of the world, from Al-Qaeda to Daesh,” Rouhani told the General Assembly. (Daesh is another name for ISIS.) “The extremists of the world have found each other and have put out the call: ‘Extremists of the world unite.’ But are we united against the extremists?”

Rouhani blamed unnamed intelligence agencies, implicitly in oil-rich Arab countries, for putting “blades in the hands of madmen, who spare no one.” And he indicted the West, for “strategic blunders” that spawned havens of chaos exploited by extremists, particularly in Iraq and Afghanistan. He challenged the legality of the new U.S.-led military campaign in Syria, operating without an international mandate or an invitation by the Syrian government. (Iraq did request intervention.) He suggested that bombing Syria was a violation akin to Russia’s intervention in Ukraine.

As in previous U.N. speeches by Iranian leaders, Rouhani portrayed the Islamic Republic as ever the innocent neighbor, victimized by others’ misdeeds. Iran is actually on the State Department’s official list for sponsoring terrorist groups, including Lebanon’s Hezbollah and Palestinian Hamas. For three years, Iran’s aid, arms, and advisers have helped Syria’s President, Bashar al-Assad, to beat back both secular rebels and Islamic extremists.

But the ISIS threat has generated a new willingness, even among naysayers, for Tehran and Washington to listen to each other, despite differences over what to do about it. Rouhani’s language, including a reference to the “savages’’ of the Islamic State, echoed the speeches of Obama and other Western leaders at the U.N. this week.

The mood at the dinner was subdued, even somber, I am told. After a meal of Middle Eastern dishes, heavy on lamb and rice, Rouhani engaged in a give-and-take for almost two hours. Among his guests were the former Secretary of State Madeleine Albright, the former national-security advisers Stephen Hadley, Samuel Berger, and Brent Scowcroft, the former Joint Chiefs of Staff Chairman Admiral Mike Mullen, and the former congresswoman Jane Harman, who served on the House Intelligence, Homeland Security, and Armed Services Committees.

“It was a pretty stellar group of Americans,” James Dobbins, a special envoy to crisis zones for the Clinton, Bush, and Obama Administrations, told me. “It was a tribute to the importance of the issues and our fascination with the individual that the Iranians could attract such a group.” The event was coördinated by the New America Foundation, a Washington think tank led by Anne-Marie Slaughter, a former head of the State Department’s Policy Planning Staff, and Suzanne DiMaggio.

Rouhani, a mid-ranking Shiite cleric who wears a white turban (signifying that he is not a descendant of the Prophet Muhammad), took five questions at a time.

“Some he dodged. Some weren’t answered satisfactorily. But some were very interesting exchanges,” Berger, Bill Clinton’s national-security adviser, said. “I was impressed by him. My impression was that he wants a [nuclear] agreement. I think he sees it as an important path. Whether we have the room or they have the flexibility, I don’t know.”

Reactions varied widely. Some guests felt that Rouhani genuinely wants to do business with the United States. “He wants to engage, and I think that’s very positive,” Scowcroft, George H. W. Bush’s national-security adviser, told me. “One of our problems with Iran for a number of years has been that the mullahs, or whoever runs the place, have not wanted real engagement.”

But another former official, who did not want to be quoted, was scornful of Rouhani, and others were skeptical. Hadley, George W. Bush’s national-security adviser, described Iran’s President as “formidable” and “tough,” even when Rouhani was arguing that nuclear talks could be “a stepping stone” for future collaboration with the United States.

Robert Einhorn, who until last year was a member of the U.S. nuclear-negotiation team and is now at the Brookings Institution, said, “The theme he was trying to stress was that a nuclear deal was a gateway opportunity, and if only there was political will on the nuclear issue then there’d be real opportunity to coöperate on a whole range of issues. He mentioned it four or five times.”

One of those issues is Afghanistan, which shares a five-hundred-and-seventy-mile border with Iran. In 2001, after the Taliban was ousted, the world’s only theocracy and its most powerful democracy, in a rare collaboration, worked together on forming a new government. Dobbins and the current Iranian foreign minister, Javad Zarif, were the primary brokers. Both were at the dinner. Now Iran and the U.S. are worried about whether Afghanistan, still a fractured country, can survive political fissures after a disputed election, in the midst of a Taliban insurgency, and with NATO drawing down military forces.

“They called on me, so I said a few words about Afghanistan,” Dobbins told me. “I said that a few weeks ago we almost saw the overthrow of an Afghan constitutional order that Iran and the U.S. had worked together to put in place. We’ve overcome those difficulties, but a new national unity government is very fragile and needs support. I said we’d be more successful if Iran and the United States collaborated more closely. Rouhani responded positively. He effectively confirmed that our approaches were similar.”

Rouhani’s answers were “reasonable, in the main, except when he had to defend Syria,” the career diplomat Thomas Pickering told me. “He did try to strike the right note and find helpful things to say, but he didn’t give away for free things he was hanging on to. He knew his brief.” As for Rouhani’s decision not to shake hands with Obama this year, Pickering said, “Why do it if it would not get him an answer on the major question and might get some serious backlash back home? Why do it if it’s not going to push the ball ahead in the future in a way that would bring him tangible benefits or get sanctions lifted?”

At a breakfast that I and other journalists attended with Rouhani on the same day as the dinner, the Iranian leader acknowledged that any nuclear deal was likely to face a “dust bowl” backlash from conservatives in Tehran.