An exchange of letters between Barack Obama and the Iranian president, Hassan Rouhani, has set the stage for a possible meeting between the two men at the UN next week in what would be the first face-to-face encounter between a US and Iranian leader since Iran's 1979 revolution.

Britain's foreign secretary, William Hague, is also due to meet his Iranian counterpart, Mohammad Javad Zarif, at the UN general assembly meeting in New York, adding to guarded optimism that the June election of Rouhani, a Glasgow-educated moderate, and his appointment of a largely pragmatic cabinet, has opened the door to a diplomatic solution to the 11-year international standoff over Iran's nuclear programme.

Tehran took the Foreign Office by surprise, tweeting on Rouhani's English-language feed that the president would also be prepared to meet Hague, something the UK had not even requested.

"Tehran has responded positively to UK's request. President Rouhani's meeting w/WilliamJHague on the sidelines of UNGA has been confirmed," the tweet said.

"We would be happy to meet," a Foreign Office spokeswoman said, "but we have had nothing formal from Tehran about it."

Diplomats said that the tweet reflected the new Iranian government's eagerness to make diplomatic headway on the nuclear issue, which has been at an impasse for several years. A Hague meeting with either Rouhani or Zarif could clear the way to restoring full diplomatic ties, which have not existed since the British embassy in Tehran was ransacked by a mob in November 2011.

In a television interview aired on Sunday, Obama made clear that there was a diplomatic opening with Iran, not only over the nuclear question but also over Syria. He confirmed earlier reports that he and Rouhani had "reached out" to each other, exchanging letters.

US officials were sceptical about a Rouhani meeting, but some observers said the Geneva deal on Syria's chemical weapons has opened new space for global diplomacy.

Trita Parsi, head of the National Iranian American Council and an expert on US-Iran diplomacy, said "I think there is a chance [of a meeting]. It would be a strong political push for movement. If Obama got involved, it would be the infusion of political will needed to reach an agreement.

"Tehran is already claiming some of the credit for the Syria deal. Rouhani needs to show that through his diplomatic efforts he has already avoided a war. He is desperate in his first six months to show his approach has paid more dividends than the hardline approach of his predecessor."

Parsi added that if Obama was to meet Rouhani it was likely to be an orchestrated encounter in a corridor, rather than a sit-down talk, "to give both sides deniability". The last encounter between an American and Iranian leader was when Jimmy Carter met the Shah, Mohammad Reza Pahlavi, in 1977.

Speaking on ABC's This Week, Obama raised the prospect of Iran getting involved in broader talks on Syria if Tehran recognised "that what's happening there is a train wreck that hurts not just Syrians but is destabilising the entire region". He said the Geneva deal could pave the way for more general talks involving Russia and Iran aimed at "some sort of political settlement that would deal with the underlying terrible conflict".

In the same interview, Obama also urged Iran's leadership not to draw the wrong lessons from his decision to draw back from air strikes on Syria in pursuit of a diplomatic solution to the chemical weapons crisis. He said it showed that it was possible to resolve the standoff over Iran's nuclear aspirations peacefully, but insisted it did not indicate a weakening of US resolve to stop the proliferation of weapons of mass destruction.

"I think what the Iranians understand is that the nuclear issue is a far larger issue for us than the chemical weapons issue, that the threat against … Israel that a nuclear Iran poses is much closer to our core interests. That a nuclear arms race in the region is something that would be profoundly destabilising," Obama said in the ABC interview, which was recorded on Friday, before a final Syria deal with Russia was struck in Geneva.

"My suspicion is that the Iranians recognise they shouldn't draw a lesson that [because] we haven't struck to think we won't strike Iran," Obama said, in remarks that may also have been intended as a reassurance to Israel that US deterrence against any Iranian attempt to build nuclear weapons had not been weakened.

After meeting John Kerry, US secretary of state, the Israeli prime minister, Binyamin Netanyahu, stressed the same point. "The determination the international community shows regarding Syria will have a direct impact on the Syrian regime's patron – Iran," Netanyahu said. "Iran must understand the consequences of its continued defiance of the international community by its pursuit toward nuclear weapons," he added.

However, Obama insisted: "What they should draw from this lesson is that there is the potential of resolving these issues diplomatically. You know, negotiations with the Iranians are always difficult. I think this new president is not going to suddenly make it easy. But you know, my view is that … if you have both a credible threat of force, combined with a rigorous diplomatic effort, that, in fact you can strike a deal."