Donald Trump and Iran’s president Hassan Rouhani have suggested they would be willing to sit down to hammer out their country’s differences.

The two leaders may meet at the United Nations General Assembly session next month – and could cool down fears of a broader war in the Middle East.

“I believe we need to use every possible tool to further our country’s national interests,” Mr Rouhani said during a speech broadcast on state television. “If I am sure that attending a session or having a meeting with someone will help develop my country and resolve the people’s problems, I will not hesitate to do so.”

Hours later, Mr Trump, responding to a reporter’s question, said that he could foresee talks with Iranian officials within weeks. “I don’t know the gentleman,” he said of Mr Rouhani. “I tell you one thing, he’s a great negotiator. I think he’s going to want to meet. I think Iran wants to get this situation straightened out.”

Iran’s supreme leader Ali Khamenei, a severe critic of the US who has long been sceptical of any negotiations between Tehran and Washington, is the ultimate power in Iran. He would hold the final say over whether Mr Rouhani could meet Mr Trump, who has repeatedly made it clear he is willing.

Mr Rouhani has previously refused to meet Mr Trump’s successor, Barack Obama, but his speech marked a rare moment when he said he would be willing to meet Iran’s greatest adversary without citing preconditions.

The apparent willingness to meet comes amid a flurry of diplomatic activity meant to salvage the 2015 Joint Comprehensive Plan of Action (JCPOA), the nuclear deal negotiated by Iran and world powers.

The potential diplomatic opening came a day after Iran’s foreign minister, Mohammad Javad Zarif, paid a surprise visit to world leaders at the G7 summit in Biarritz at the invitation of its host, French president Emmanuel Macron.

Both Mr Rouhani and Mr Trump will be in New York for the UN’s annual General Assembly meeting, which begins on 17 September.

Western diplomats see it as an opportunity for talks between the two countries, according to analysts.

A deal or at least some sort of informal modus vivendi between Iran and the US could also halt what many regard as a dangerous escalation of military manoeuvering and posturing throughout the Middle East. In recent times, the Middle East and Persian Gulf have been best by airstrikes, the sabotaging and grabbing of oil tankers, and drone attacks by Iran and the US, and their various proxies and allies.

“It’s a sign that diplomacy has more power and influence than this escalation and provocative threatening dynamic,” said Sanam Vakil, an Iran expert at Chatham House who is preparing a paper on the backroom diplomacy surrounding Iran. “It indicates that there is a willingness on all sides to come back to the negotiating table. Behind the scenes, they’re dancing around each other trying to determine what the negotiations will be, and when they could happen.”

In Biarritz, Mr Zarif met top UK, French and German officials attempting to rescue the JCPOA – but did not meet Mr Trump.

The US president said afterwards he had agreed to Mr Zarif’s arrival, insisting that all world leaders were on the same page regarding Iran’s nuclear programme.

But meetings between European leaders and Mr Zarif, whom the US recently sanctioned at the behest of Washington hardliners, strongly suggested otherwise. Photos showed Mr Zarif and top European officials, jackets off, speaking for hours just a stone’s throw from Mr Trump at the $600 a night Hotel du Palais.

The Democrat challengers to Trump in 2020 Show all 25 1 /25 The Democrat challengers to Trump in 2020 The Democrat challengers to Trump in 2020 Bernie Sanders The Vermont senator has launched a second bid for president after losing out to Hilary Clinton in the 2016 Democratic primaries. He is running on a similar platform of democratic socialist reform Getty The Democrat challengers to Trump in 2020 Joe Biden The former vice president recently faced scrutiny for inappropriate touching of women, but was thought to deal with the criticism well and has since maintained a front runner status in national polling EPA The Democrat challengers to Trump in 2020 Elizabeth Warren The Massachusetts senator is a progressive Democrat, and a major supporter of regulating Wall Street Reuters The Democrat challengers to Trump in 2020 Amy Klobuchar Klobuchar is a Minnesota senator who earned praise for her contribution to the Brett Kavanaugh hearings Getty The Democrat challengers to Trump in 2020 Michael Bloomberg Michael Bloomberg, a late addition to the 2020 race, announced his candidacy after months of speculation in November. He has launched a massive ad-buying campaign and issued an apology for the controversial "stop and frisk" programme that adversely impacted minority communities in New York City when he was mayor Getty Images The Democrat challengers to Trump in 2020 Tulsi Gabbard The Hawaii congresswoman announced her candidacy in January, but has faced tough questions on her past comments on LGBT+ rights and her stance on Syrian President Bashar al-Assad Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Pete Buttigieg The centrist Indiana mayor and war veteran would be the first openly LGBT+ president in American history Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Deval Patrick The former Massachusetts governor launched a late 2020 candidacy and received very little reception. With just a few short months until the first voters flock to the polls, the former governor is running as a centrist and believes he can unite the party's various voting blocs AFP/Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Beto O'Rourke The former Texas congressman formally launched his bid for the presidency in March. He ran on a progressive platform, stating that the US is driven by "gross differences in opportunity and outcome" AP The Democrat challengers to Trump in 2020 DROPPED OUT: Kamala Harris The former California attorney general was introduced to the national stage during Jeff Sessions’ testimony. She has endorsed Medicare-for-all and proposed a major tax-credit for the middle class AFP/Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Bill De Blasio The New York mayor announced his bid on 16 May 2019. He emerged in 2013 as a leading voice in the left wing of his party but struggled to build a national profile and has suffered a number of political setbacks in his time as mayor AFP/Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Steve Bullock The Montana governor announced his bid on 14 May. He stated "We need to defeat Donald Trump in 2020 and defeat the corrupt system that lets campaign money drown out the people's voice, so we can finally make good on the promise of a fair shot for everyone." He also highlighted the fact that he won the governor's seat in a red [Republican] state Reuters The Democrat challengers to Trump in 2020 DROPPED OUT: Cory Booker The New Jersey Senator has focused on restoring kindness and civility in American politics throughout his campaign, though he has failed to secure the same level of support and fundraising as several other senators running for the White House in 2020 Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Wayne Messam Mayor of the city of Miramar in the Miami metropolitan area, Wayne Messam said he intended to run on a progressive platform against the "broken" federal government. He favours gun regulations and was a signatory to a letter from some 400 mayors condemning President Trump's withdrawal from the Paris Climate Accord Vice News The Democrat challengers to Trump in 2020 DROPPED OUT: Kirsten Gillibrand The New York Senator formally announced her presidential bid in January, saying that “healthcare should be a right, not a privilege” Getty The Democrat challengers to Trump in 2020 DROPPED OUT: John Delaney The Maryland congressman was the first to launch his bid for presidency, making the announcement in 2017 AP The Democrat challengers to Trump in 2020 DROPPED OUT: Andrew Yang The entrepreneur announced his presidential candidacy by pledging that he would introduce a universal basic income of $1,000 a month to every American over the age of 18 Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Julian Castro The former San Antonio mayor announced his candidacy in January and said that his running has a “special meaning” for the Latino community in the US Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Marianne Williamson The author and spiritual adviser has announced her intention to run for president. She had previously run for congress as an independent in 2014 but was unsuccessful Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Eric Swalwell One of the younger candidates, Swalwell has served on multiple committees in the House of Representatives. He intended to make gun control central to his campaign but dropped out after his team said it was clear there was no path to victory Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Seth Moulton A Massachusetts congressman, Moulton is a former US soldier who is best known for trying to stop Nancy Pelosi from becoming speaker of the house. He dropped out of the race after not polling well in key states Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Jay Inslee Inslee has been governor of Washington since 2013. His bid was centred around climate change AFP/Getty The Democrat challengers to Trump in 2020 DROPPED OUT: John Hickenlooper The former governor of Colorado aimed to sell himself as an effective leader who was open to compromise, but failed to make a splash on the national stage Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Tim Ryan Ohio representative Tim Ryan ran on a campaign that hinged on his working class roots, though his messaging did not appear to resonate with voters Getty The Democrat challengers to Trump in 2020 DROPPED OUT: Tom Steyer Democratic presidential hopeful billionaire and philanthropist Tom Steyer is a longtime Democratic donor AFP/Getty

“It’s an acceleration of the shuttle diplomacy that the French president has been involved with between DC and Tehran,” said Ellie Geranmayeh, an Iran specialist at the European Council on Foreign Relations. “The Zarif surprise visit indicates the seriousness of the negotiations and backchannel talks that are happening at the moment through France.”

Mr Macron was reportedly attempting to broker a deal between Tehran and Washington that would keep Iran in the JCPOA, the nuclear agreement, in exchange for easing some restrictions on Iranian oil sales. Since unilaterally pulling out of the deal last year, the US has vowed to punish any entity that purchases Iranian oil, the lifeblood of its economy.

Iran has responded by slowly easing some of its commitments to the nuclear deal and threatening to further roll back compliance. It has also threatened Persian Gulf oil traffic, rattling the global energy business.

Few believe the erratic Mr Trump would quickly agree to a comprehensive deal that could convince Iranians to give in to America’s conditions. These include a severe scaling back of the Iranian nuclear programme, curtailing of its missile development, and halting its support for armed allies across the Middle East.

But Mr Macron’s gambit appeared to be an attempt to use a touch of showbiz spectacle to seduce the former reality TV star into diplomacy, and convince him that a high-profile agreement with Iran was within his grasp.

“All that has to happen is for the Trump administration to respond to the French suggestion positively,” said Esfandyar Batmanghelidj, a researcher and consultant regularly in touch with Iranian officials and European diplomats.

“It’s not about coming up with a new mechanism to allow sales of Iranian oil, but to use Europe’s political capital to push Trump to ease the maximum pressure campaign specifically by restoring some of the oil waivers, in exchange for building a little bit of trust on both sides and getting us off this cycle of escalation,” he said.

Iranian lawmakers have demanded Mr Zarif brief them on his return to Tehran. Any potential deal could die a quick death within the crossfire of Iranian domestic politics.

Mr Zarif’s visit has also enraged ideologically committed Washington hardliners who have the president’s ear on Iran policy and have been goading the White House to continue a policy of “maximum pressure” against Tehran.

Mark Dubowitz, head of the influential Foundation for the Defence of Democracies, blasted France for having “feted” Mr Zarif a day after Tehran placed him and his think tank on a sanctions list.

Mr Dubowitz insisted he could now be in the crosshairs of Iranian security operatives who have regularly targeted dissidents and opponents abroad.

The Trump administration’s top security officials, including secretary of state Mike Pompeo and national security adviser John Bolton, have also repeatedly staked out a tough set of conditions for lifting sanctions on Iran that are crippling its economy.

“They’re really hurting badly,” Mr Trump said on Monday. “Their inflation is through the roof. Their economy has tanked entirely. The sanctions are absolutely hurting them horribly. I don’t want to see that. They’re great people.”

But Mr Trump is also motivated to make a deal. With his trade war against China damaging the world economy, and his international friends such as Saudi Crown Prince Mohamed bin Salman and Brazilian president Jair Bolsonaro under worldwide condemnation, as well as negotiations with North Korea over its weapons programmes bogged down, Mr Trump could use a foreign policy victory ahead of 2020 elections.

“Both sides are keen to find ways to de-escalate,” said Ms Geranmayeh.

Tehran appears to detect Trump’s vulnerability.

“We have unseated an American president in the past,” Mr Rouhani’s foreign policy adviser, Hesameddin Ashena, tweeted last month in reference to the widespread belief that the taking of US hostages in 1979 destroyed president Jimmy Carter’s chances for a second term. “We can do it again.”