In a joint statement, the leaders of 18 nations and the EU recognised the US decision to withdraw from the Paris climate agreement.
However, they also said other G20 members remained committed to the “irreversible” accord.
Deadlock over the issue had held up the last day of talks in Hamburg.
A final agreement was eventually reached and the joint summit statement was officially released on Saturday.
The statement also said the US would “endeavour to work closely with other countries to help them access and use fossil fuels more cleanly and efficiently”.
The Paris accord is an agreement between nations to commit to restrict global temperature increases.
In her closing news conference, German Chancellor Angela Merkel, who hosted the summit in Hamburg, said she still deplored Mr Trump’s position but that she was “gratified” the other 19 nations opposed its renegotiation.
However Turkish President Recep Tayyip Erdogan later said that his country’s ratification of the Paris accord was now in doubt, as the US withdrawal jeopardised compensation for developing countries.
Mr Erdogan said that when Turkey signed the accord, France had promised that Turkey would be eligible for compensation for some of the financial costs of compliance.
“So we said if this would happen, the agreement would pass through parliament. But otherwise it won’t pass,” Mr Erdogan told a news conference, adding that parliament had not yet approved it.
Mr Trump also won a concession on trade, with leaders underlining the right of countries to protect their markets with what they referred to as legitimate trade defence instruments.
He later tweeted: “The #G20Summit was a wonderful success and carried out beautifully by Chancellor Angela Merkel. Thank you!”
North Korea talks
Mr Trump held his final talks of the event with Chinese President Xi Jinping, and the two leaders discussed efforts to rein in North Korea’s nuclear ambitions.
The US president told his Chinese counterpart that “something has to be done” after Pyongyang tested an intercontinental ballistic missile with the potential to hit the US state of Alaska on Tuesday.
President Xi said he supported denuclearisation of the Korean peninsula, and said the China US relationship had made “progress… despite some sensitive issues”, state news agency Xinhua said.
Mr Xi suggested visits between the two countries’ defence ministers, Xinhua added.