By Agence France-Presse
Here are some of the top moments and bon-mots from the two-day meeting hosted by Japan in the city of Osaka:
It was the summit within a summit: the long-awaited meeting between US President Donald Trump and China's Xi Jinping to thrash out a truce in the trade war between the world's top two economies.
And when the meeting was over, Trump delivered the news everyone had been waiting for: "We are right back on track," the US president said after talks he described as "excellent."
There were precious few details on what the two leaders had agreed, beyond a committment to resume trade negotiations and hold off on tariffs, offering the world economy some breathing space for now.
Climate change heat
At a summit expected to be dominated by trade, climate change proved an unexpected hot potato, with France's Emmanuel Macron saying the issue was a "red line" before talks even began.
"My lines don't have colours," joked European Commission President Jean-Claude Juncker, who nonetheless agreed that strong action was needed.
Negotiators worked through the night to agree language that mirrored that of the last G20, claiming it as a small victory.
"We avoided going backwards... but we must go much further," Macron said after the summit.
North Korea, but no Iran
With tensions spiralling in the Gulf, Iran was expected to be a key focus at the summit and bilateral meetings, but it was barely mentioned, with Trump instead stealing the show in a surprise tweet... on North Korea.
"If Chairman Kim of North Korea sees this, I would meet him at the Border/DMZ just to shake his hand and say Hello(?)!" Trump tweeted, inviting Kim Jong Un to meet for a historic handshake at the demilitarised zone that divides the Korean peninsula.
The tweet came before Trump headed to South Korea, and he insisted he would have "no problem" stepping into the North with Kim if invited.
All the president's men
In person, Trump played nice with world leaders who he has not hesitated to criticise in tweets and interviews, but he appeared most at ease in the company of some of the group's most controversial members, including Russian President Vladimir Putin.
The pair smiled and joked about "fake news", and when Trump was asked if he would tell Putin not to interfere in US elections, he turned to the Russian president with a grin.
"Don't meddle in the election, president, don't meddle," he said, wagging his finger jokingly at the Kremlin strongman.
Trump also showered praise on Saudi Crown Prince Mohammed bin Salman, despite accusations of his involvement in the murder of journalist Jamal Khashoggi.
And he posed with off his signature thumbs up for a photo with Brazil's right-wing President Jair Bolsonaro, sometimes dubbed the 'Trump of the Tropics.'
- Nobody reads the communique -
Negotiators laboured through the night to get agreement on a final communique that warned "most importantly, trade and geopolitical tensions have intensified", endorsing language in a hard-won statement from the group's finance ministers earlier this month.
On climate, they won a deal to repeat the so-called 19+1 formula, with 19 countries endorsing the "irreversibility" of the Paris climate agreement while Washington repeated its plans to withdraw from the accord.
But Juncker made a candid admission even as negotiations were ongoing, saying jetlag had prompted him to break a longstanding tradition of not reading the communique.
"I'm not the only one in this room who does not read the communique. Nobody in fact reads the communique."