The US president is understood to have been pressing states including Brazil, Turkey, Australia and Saudi Arabia to join him in keeping any reference to the Paris agreement on reducing carbon emissions out of the summit communique.
At one point it seemed possible that the leaders would be unable to agree a final statement at all. French president Emmanuel Macron, the architect of the climate deal, reportedly warned he would refuse to sign off a joint statement unless it was included.
But the communique eventually agreed at the conclusion of the two-day gathering in Osaka repeated earlier commitments by 19 of the G20 members to the “irreversibility” of the Paris accord and its full implementation.
As in last year’s summit in Argentina, the statement noted that the US had pulled out of the climate agreement and was not committed to deliver on its goals.
A senior British government official acknowledged that the process of drawing up the summit communique was “challenging”.
The “sherpas” – officials who do the groundwork for national leaders at major summits – had “a long night” finding acceptable wording not only on climate but also on trade, he said.
Theresa May welcomed the final outcome, though she said it had not been “easy” to achieve. She made clear she regarded it as a success that the 20 members – 19 countries and the EU – had been able to fashion a statement that all could sign.
“There is a communique from this summit and I think that is important,” she said.
“What you see in that communique is a continuation of the support that 19 members of the G20 have for the Paris agreement.
“Nineteen countries have come together and reconfirmed our commitment to the irreversibility of the Paris agreement and our commitment to putting that agreement into place.”
Ms May made a strongly worded intervention in the discussion on climate change at Osaka, urging other nations to follow the UK’s lead in legislating for a target of net zero carbon emissions by 2050.
She said: “In recent months we have heard hundreds of thousands of young people urge us – their leaders – to act on climate change before it’s too late.
“I am proud that the UK has now enshrined in law our world-leading net zero commitment to reduce emissions. And I have called on other countries to raise their ambition and embrace this target.”
In a message apparently directed at Mr Trump, Ms May made a firm statement of support for international institutions and the rules-based systems which underpin world trade and security.
“I firmly believe in the importance of international co-operation and compromise,” she said. “In Osaka this week we have worked hard to bridge differences between the G20 countries on some of the biggest challenges our nations face.
“That has not been easy but we have made progress. I continue to believe that we are stronger when we work together.“
And she added: “The UK has never been afraid to stand up for the global rules that underpin our values and our way of life.
“The UK remains committed to the global rules-based trade system and trade that is fair as well as free and we believe that all nations must be encouraged to uphold these rules and open their markets if we are to build economies that truly work for everyone.”
The UK is bidding in partnership with Italy to host the COP26 climate summit in 2020, a major gathering expected to attract up 30,000 delegates including 150 world leaders.
Ms May’s government has said it has the advantage because the UK has the world’s most concentrated grouping of scientific, civil society and business expertise on climate change that would help develop the programme and objectives for the summit.
Join our commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies