Zarif's presence had not been announced and represented a gamble by French host Emmanuel Macron who is seeking to soothe spiralling tensions between Iran and the United States.

The Iranian top diplomat did not hold talks with US President Donald Trump in the French surf town, French diplomats said, but the presence of the two men in the same place sparked hopes of a detente.

"Road ahead is difficult. But worth trying," the US-educated Zarif wrote on Twitter after meeting Macron and French Foreign Minister Jean-Yves Le Drian as well as British and German officials.

French officials said Trump had been aware of the arrival and suggested that it had been discussed during an impromptu two-hour lunch with Macron on a hotel terrace on Saturday.

"We work with full transparency with the Americans," one diplomat told reporters on condition of anonymity.

Robert Malley, head of the International Crisis Group, a think-tank, said that it was a sign that Trump had given "some positive response" to Macron's proposals for a deal.

"Maybe President Trump told President Macron privately that he was open to some of these ideas," he told AFP.

"The big caveat, the elephant in the room, is that there is considerable room between what President Trump says and what he thinks one day, and what he says and thinks the next," he added.

Also speaking in Biarritz, US Treasury Secretary Steven Mnuchin said that Trump had in the past said that if Iran "wants to sit down and negotiate he will not set preconditions."

French officials said the discussions had been "positive" and Zarif left the beach-side gathering in the evening.

- 'Moving in right direction' -

Macron had held talks with Zarif in Paris on the eve of the G7 summit and has been leading efforts to bring Tehran and Washington back to the negotiating table.

Trump's policy of applying "maximum pressure" on Tehran via crippling sanctions has been criticised by European powers and is seen as raising the risk of conflict in the Middle East.

At the end of July, the US Treasury imposed sanctions on Zarif, saying he "spreads the regime’s propaganda and disinformation."

Macron has urged the US administration to offer some sort of relief to Iran, such as lifting sanctions on oil sales to China and India, or a new credit line to enable exports.

In return, Iran would return to complying with a landmark 2015 deal limiting its nuclear programme, which Trump unilaterally pulled out from last year, Malley explained.

"I suspect that they (the French) are as cautious as I am," Malley added.

Speaking to AFP last week, Zarif said that Macron's suggestions were "moving in the right direction, although we are not definitely there yet."

Zarif was a key architect of the 2015 nuclear deal reached between Iran, the United States, European powers, Russia and China.

- Trade war doubts? -

The G7 leaders, spouses and other invitees from South America and Africa wrapped up their long day with a group photo on a stage overlooking the Biarritz beach, with the city's tall lighthouse in the background.

They were all smiles and Trump proclaimed that the G7 summit had been going "beautifully."

However, there was no masking over cracks between the US president and his allies on many issues.

Leaders of the G7 countries -- Britain, Canada, France, Germany, Italy, Japan and the United States -- put on a united front as they spent a second day in the high-end French surfing town of Biarritz.

Trump arrived in Biarritz fresh from having drastically upped the ante in the trade war with China.

European leaders lined up to press for caution and on Sunday Trump gave a glimmer of hope that he was reconsidering his all-or-nothing approach to the dispute between the world's two biggest economies.

Asked whether he was having second thoughts about the trade war, Trump, in a rare moment of public self-doubt, replied: "I have second thoughts about everything."

Then in an extraordinary turnaround, Trump's spokeswoman Stephanie Grisham said just hours later that the president had been misunderstood.

He did have regrets, she said, but not what everyone thought.

"He regrets not raising the tariffs higher," she explained.

At a breakfast meeting, British Prime Minister Boris Johnson became the latest of the G7 partners to urge Trump to step back from a trade war that critics fear could tip the world economy into recession.

"Just to register a faint, sheep-like note of our view on the trade war -- we are in favour of trade peace on the whole," Johnson told Trump.

The meeting with Johnson, who is sometimes seen as a British version of the populist, nationalist Trump, underlined the White House's dislike for the powerful European Union.

Trump predicted that Johnson would manage to untangle the mess of Brexit and described the EU as "an anchor around their ankle."