About 190 nations have agreed upon the building blocks of a deal to combat climate change in 2015 amid warnings that far tougher action will be needed to cut rising world greenhouse-gas emissions.
The Lima deal, reached early on Sunday, lays out a wide range of options for a global deal to be reached in Paris, due in December 2015, and also lays out how each nation will submit its own plans for curbing warming in the first half of 2015.
It is a watered-down version of the original deal following an extra day of bargaining between rich and poor countries.
Negotiators had been struggling to unblock the UN climate talks after developing countries rejected a draft deal they said would allow rich countries to shirk their responsibilities to fight global warming and pay for its impacts.
Manuel Pulgar-Vidal, Peru's environment minister, presented a new, fourth draft just before midnight and said he hoped it would satisfy all parties, giving a sharply reduced body of remaining delegates an hour to review it.
"As a text it's not perfect but it includes the positions of the parties," said Pulgar-Vidal, who is conference chair and had spent all afternoon and evening meeting the delegations separately.
The main goal for the two-week session in Lima was relatively modest: to reach agreement on what information should go into the pledges that countries submit for a global climate pact expected to be adopted next year in Paris.
But even that became complicated as several developing nations rebelled against a draft decision they said blurred the distinction between what rich and poor countries can be expected to do.
The new draft was designed to alleviate that concern.
Meanwhile, China, the world's top carbon polluter, and other major developing countries opposed plans for a review process that would allow the pledges to be compared against one another before Paris.
The new draft mentioned only that all pledges would be reviewed a month ahead Paris to assess their combined effect on climate change.
The new draft also watered down language on the content of the pledges, saying they "may" instead of "shall" include quantifiable information showing how countries intend to meet their emissions targets.
By the time Pulgar-Vidal presented the latest draft, many delegates had left, including environment ministers who were the most senior members of negotiation teams.