More than 30 hours behind schedule, delegates from more than 190 countries agreed on what information should go into the pledges that countries submit for the expected Paris pact.
They argued all day Saturday over the wording of the decision, with developing nations worried that the text blurred the distinction between what rich and poor countries can be expected to do.
The final draft alleviated those concerns with language saying countries have "common but differentiated responsibilities" to deal with global warming.
"As a text it's not perfect, but it includes the positions of the parties," said Environment Minister Manuel Pulgar-Vidal, who was the conference chairman and had spent most of the day meeting separately with delegations.
The momentum from last month's joint U.S.-China deal on emissions targets faded quickly in Lima as rifts reopened over who should do what to fight global warming. The goal of the talks is to shape a global agreement in Paris that puts the world on a path to reduce the heat-trapping gases that scientists say are warming the planet.
Many developing countries, the most vulnerable to climate change's impacts, accuse rich nations of shirking their responsibilities to curb climate change and pay for the damage it inflicts.
In presenting a new, fourth draft just before midnight, Peru's environment minister gave a sharply reduced body of delegates an hour to review it. Many delegates had already quit the makeshift conference centre on the grounds of Peru's army headquarters.
It also restored language demanded by small island states at risk of being flooded by rising seas, mentioning a "loss and damage" mechanism agreed upon in last year's talks in Poland that recognizes that nations hardest hit by climate change will require financial and technical help.
"We need a permanent arrangement to help the poorest of the world," Ian Fry, negotiator for the Pacific Island nation of Tuvalu, said at a midday session.
However, the approved draft weakened 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.
Also, top carbon polluter China 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.
"I think it's definitely watered down from what we expected," said Alden Meyer of the Union of Concerned Scientists.
Sam Smith, chief of climate policy for the environmental group WWF, said: "The text went from weak to weaker to weakest and it's very weak indeed."
Chief U.S. negotiator Todd Stern acknowledged that negotiations had been contentious but said the outcome was "quite good in the end." He had warned Saturday that failing to leave Lima with an accord would be "seen as a serious breakdown" that could put the Paris agreement and the entire U.N. process at risk.
Though negotiating tactics always play a role, virtually all disputes in the U.N. talks reflect a wider issue of how to divide the burden of fixing the planetary warming that scientists say results from human activity, primarily the burning of oil, coal and natural gas.
Historically, Western nations are the biggest emitters. Currently, most CO2 emissions are coming from developing countries led by China and India as they grow their economies and lift millions of people out of poverty.
During a brief stop in Lima on Thursday, U.S. Secretary of State John Kerry said fixing the problem is "everyone's responsibility, because it's the net amount of carbon that matters, not each country's share."
According to the U.N.'s scientific panel on climate change, the world can pump out no more than about 1 trillion tons of carbon to have a likely chance of avoiding dangerous levels of warming —defined in the U.N. talks as exceeding 2 degrees centigrade (3.6 degrees Fahrenheit) above 19th-century averages.
It already has spent more than half of that carbon budget as emissions continue to rise, driven by growth in China and other emerging economies.
Scientific reports say climate impacts are already happening and include rising sea levels, intensifying heat waves and shifts in weather patterns causing floods in some areas and droughts in others.
The U.N. weather agency said last week that 2014 could become the hottest year on record.
Associated Press writers Frank Bajak and Nestor Ikeda contributed to this report.
Also on HuffPost: