Mohammad Javad Zarif landed on Sunday in the French seaside town of Biarritz, where leaders of the G7 nations - Canada, France, Germany, Italy, Japan, the United Kingdom, and the United States - were meeting to discuss a host of issues, including global trade, climate change and Iran's nuclear programme.
Zarif immediately went into a three-and-a-half-hour meeting with French foreign minister, Jean-Yves Le Drian, according to Reuters news agency.
He spent half an hour with Macron, the second meeting in a week after the two leaders had met in Paris on Friday.
Zarif did not meet Trump, who was also at the G7 meeting.
"Iran's active diplomacy in pursuit of constructive engagement continues," Zarif said in a post on social media. "Road ahead is difficult. But worth trying."
His plane departed moments after the whirlwind meeting ended.
An official in Macron's office told AFP the discussions were "positive".
Macron decided to invite the Iranian foreign minister to Biarritz after hosting a dinner of G7 leaders on Saturday night, a French official told AFP.
The invite had been made "in agreement with the United States", the official added, contradicting a claim by the White House that Trump had not been informed of Zarif's arrival.
Macron had also hosted Zarif for talks in Paris on the eve of the summit on Friday.
Following the meeting, Zarif said the French president's suggestions were positive for Iran but that a lot more work was needed on the matter.
“President Macron made some suggestions last week to President (Hassan) Rouhani and we believe they are moving in the right direction, although we are not definitely there yet,” said in an interview with AFP after the interview.
Macron, the host of this year's G7 summit, has been leading efforts to defuse tensions triggered by US President Donald Trump's decision to pull out of an international agreement that offered Iran sanctions relief in exchange for curbs on its nuclear programme.
After its exit, Washington reimposed punishing sanctions on Iran, including on its oil and banking sectors.
While the nuclear deal's remaining signatories - China, France, Germany, Russia, and the UK - oppose the US move, they have struggled to protect Iran from US sanctions.
The French president is urging Trump to offer some sort of relief to Iran, according to Reuters and AFP, such as lifting sanctions on oil sales to China and India, or establishing a new credit line to enable exports.
Relief from 'maximum pressure'
A French diplomat told reporters last week that a "pause" in Trump's maximum pressure campaign against Tehran was necessary to get Iran back to the negotiating table.
Trump has said he wants to force Iran into new talks that would include its ballistic missile programme and support for regional armed groups. But Iran has rejected that, saying Washington could not be trusted.
A year after the US exit, Tehran began scaling back some of its commitments under the nuclear accord.
In July, Washington imposed sanctions on Zarif, blocking any property or interest he had in the US. Zarif said he had none.
US officials said the censure was meant to send a "clear message" to Iran as tensions further escalated over alleged Iranian aggressions in the Strait of Hormuz, a significant trade route in the Gulf.
Al Jazeera's Assed Baig, reporting from Tehran, said Zarif's visit to the G7 summit highlighted the interest of Iranian politicians - in particular, Iran's President Hassan Rouhani - in salvaging the 2015 nuclear accord.
"[The negotiations are taking place] to save the reputations of those political leaders in Iran that backed this nuclear deal," he said from Tehran.
Zarif's unannounced visit played out against apparent divisions between Trump and Macron on how to deal with Iran.
Earlier on Sunday, Macron told LCI television that the G7 leaders had agreed on "what we wanted to say jointly on Iran".
Officials from the French presidency told news agencies the G7 leaders had discussed the issue over dinner on Saturday evening and agreed that Macron should hold talks and pass on messages to Iran.
Trump denied that shortly afterwards. Asked if he had signed off on a statement that Macron intends to give on behalf of the G7 on Iran, he said: "I haven't discussed this. No, I haven't."
He added: "We'll do our own outreach, but, you know, I can't stop people from talking. If they want to talk, they can talk."
Macron later played down his earlier remarks, saying there was no formal mandate from the G7 leaders.
"Yesterday, we had a discussion from which two priorities emerged. First of all, no member of the G7 wants Iran to ever get a nuclear weapon. Second, all members of the G7 are deeply committed to stability and peace in the region and therefore want to avoid actions that could compromise that," he said.
"The G7 is an informal group. There is no formal mandate given to anyone in this context. We will each continue to take initiatives to reach our two goals, that's what's important. The outcome of yesterday's discussions is that we will continue to all act, each in their own way."
Bessma Momani, professor of political science at the University of Waterloo in Canada, said France had vested interests in trying to defuse tensions between the US and Iran.
Several French companies, including car giants Peugeot and Citroen and oil firm Total, pulled out of multibillion-dollar deals with Iran following the US sanctions.
In addition to the economic interests, "Macron feels as if he is one of the sole champions of the liberal international order," Momani told Al Jazeera.
"I would even argue that perhaps Macron feels that he can sort of get some mileage out of the so-called 'bromance' he once had with Donald Trump ... But it won't be easy."
German Chancellor Angela Merkel welcomed the meeting between Zarif and Macron, saying it was worth taking every opportunity to avoid further escalation of the standoff over Iran's nuclear programme.
She said G7 leaders had "good, constructive discussion" on the subject on Saturday evening.