Trump has put in place a policy of "maximum pressure" on Iran over its disputed nuclear programme

US President Donald Trump said he was prepared to meet his Iranian counterpart Hassan Rouhani in the next few weeks after talks over Tehran's nuclear programme at a G7 summit in France.

Iranian Foreign Minister Mohammad Javad Zarif made a surprise appearance on the sidelines of the summit in Biarritz on Sunday at the invitation of French President Emmanuel Macron.

Macron said that the "conditions for a meeting" between Trump and Rouhani to take place "in the next few weeks" had been created through intensive diplomacy and consultations.

"If the circumstances were correct, I would certainly agree to that," Trump said at a joint press conference with Macron.

Asked by reporters if he thought the timeline proposed by his French counterpart sounded realistic, Trump replied: "It does", adding he thought Rouhani would also be in favour.

"I think he's going to want to meet. I think Iran wants to get this situation straightened out," Trump added.

Trump has put in place a policy of "maximum pressure" on Tehran over its disputed nuclear programme via crippling sanctions that are seen as raising the risk of conflict in the Middle East.

The US president last year unilaterally pulled out of a landmark 2015 international deal that placed limits on Tehran's nuclear activities in exchange for trade, investment and sanctions relief.

Rouhani defended Zarif's Biarritz visit in a speech aired live on state television on Monday.

"I believe that for our country's national interests we must use any tool," he said.

But hardliners have criticised the initiative, with the ultra-conservative Kayhan newspaper saying the trip was "improper" and sent "a message of weakness and desperation."

Macron has urged the US administration to offer some sort of sanctions 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 the 2015 deal.

Commenting on the talks about Iran at the G7, German Chancellor Angela Merkel said: "It's a big step forward. Now there is an atmosphere in which talks are welcomed."