Leaders of the world’s biggest economies at the G20 summit in Japan have resisted pressure from Donald Trump to water down commitments to fight climate change.

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.

Greta Thunberg inspires climate activists everywhere: In pictures Show all 12 1 /12 Greta Thunberg inspires climate activists everywhere: In pictures Greta Thunberg inspires climate activists everywhere: In pictures In the protest that started a movement, Greta skips school to sit outside of the Swedish parliament in Stockholm in order to raise awareness of climate change on 28 August 2018 Getty Greta Thunberg inspires climate activists everywhere: In pictures Greta speaks at the World Economic Forum in Davos on 25 January AFP/Getty Greta Thunberg inspires climate activists everywhere: In pictures Greta stages a protest at the World Economic Forum in Davos on 25 January Reuters Greta Thunberg inspires climate activists everywhere: In pictures Greta speaks at the House of Commons in London on 23 April PA Greta Thunberg inspires climate activists everywhere: In pictures Greta addresses to the occupation at Marble Arch in London on 21 April AFP/Getty Greta Thunberg inspires climate activists everywhere: In pictures Greta meets the pope on a visit to Rome Reuters Greta Thunberg inspires climate activists everywhere: In pictures Greta speaks at the senate in Rome on 18 April Reuters Greta Thunberg inspires climate activists everywhere: In pictures Greta addresses a debate of the EU Environment, Public Health and Food Safety committee at the European Parliament in Strasbourg on 16 April AFP/Getty Greta Thunberg inspires climate activists everywhere: In pictures Greta receives the Special Climate Protection Award at the German Film and Television awards in Berlin on 30 March AFP/Getty Greta Thunberg inspires climate activists everywhere: In pictures Greta attends a children's climate protest in Berlin on 29 March AFP/Getty Greta Thunberg inspires climate activists everywhere: In pictures Greta addresses a children's climate protest on 1 March in Hamburg Getty Greta Thunberg inspires climate activists everywhere: In pictures Greta attends a meeting for the Civil Society For rEUnaissance at the EU Charlemagne Building in Brussels on 21 February AFP/Getty

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.“

Theresa May looks completely unimpressed as she meets Vladimir Putin at G20

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.