UN members pressed ahead Sunday with a vision for a historic pact to defeat climate change by adopting a format for national pledges to cut Earth-warming greenhouse gases.
At a marathon conference in Lima, they also approved a blueprint to guide negotiations for the deal due to be sealed in Paris in December 2015.
But agreement came after a bitter dispute flared anew, requiring major compromise that campaigners said pointed to a mountain of work ahead.
"The document is approved," Peru's Environment Minister Manuel Pulgar-Vidal announced in the small hours, to wild cheers from exhausted delegates.
The annual round of talks under the UN Framework Convention on Climate Change (UNFCCC) had been scheduled to end on Friday evening, after 12 days.
Instead, it overran by 32 hours, an exceptional delay even in the tradition of the notoriously fractious UNFCCC meetings.
The hard-fought agreement—dubbed the Lima Call for Climate Action—sets down the foundations for what is envisioned to be the most ambitious agreement in environmental history.
Due to take effect in 2020, it would for the first time bind all the world's nations into a single arena for curbing heat-trapping carbon gases that drive dangerous climate change.
Its aim is to limit global warming to two degrees Celsius (3.6 degrees Fahrenheit) over pre-industrial levels, averting potentially catastrophic damage to Earth's climate system by the turn of the century.
At its core is a roster where all nations will enter voluntary commitments to reduce their carbon emissions.
But the Lima deal came at the price of a compromise to bridge a deep rift between rich and poor countries.
In the face of opposition from China, it stripped out demands for extensive information about the pledges and tougher scrutiny to see if, jointly, they close in on the 2 C target.
'Ghost of Copenhagen fading'
The document does not oblige rich nations to outline aid for poorer countries in their pledges, as the developing world had insisted.
French Foreign Minister Laurent Fabius, who will chair the December 2015 finale in Paris, said the Lima agreement had exorcised traumatic memories of the 2009 UN climate summit in Copenhagen.
That meeting had also aimed at a ground-breaking climate treaty but ended a near fiasco in a similar welter of infighting.
"The ghost of Copenhagen is fading, the hope of success in Paris is nearing," Fabius said.
Campaigners for the environment and development said the troubled UN process was still on the road, but the squabbles had exposed the problems it would face next year.
"The results in Lima are mediocre, but this is not a surprise," said Sebastien Blavier of Greenpeace France.
The decisions "represent the bare minimum needed to move the process to Paris," added the Union of Concerned Scientists (UCS), a US-based monitoring group.
"A far greater sense of urgency is needed to secure a comprehensive post-2020 climate agreement."
At the tensest moment, US envoy Todd Stern on Saturday warned the stalemate threatened the objective, set in 2011, of a new global accord.
"All we have achieved so far will be at risk, and all that we hope to achieve will be at risk as well," Stern warned delegates.
And, he said, the credibility of the UNFCCC itself was also at stake.
At the heart of the row was a years-old disagreement about dividing responsibility for carbon cuts between rich and developing nations.
Developing nations insist the West must bear a bigger burden, having started decades earlier to pollute their way to prosperity.
But rich countries point the finger at developing giants like China and India furiously burning coal to power their rapid growth.
Developing countries also wanted rich nations' carbon pledges to include commitments to financial help and adaptation aid for shoring up their climate defenses.
Scientists say the 2 C target is roughly half the warming that can be expected by 2100 on current emissions trends, placing the world on track for more frequent and severe droughts, floods, storms and fast-rising sea levels.
Emissions must be slashed by 40-70 percent by 2050 from 2010 levels and to near zero or below by 2100 for a good chance of reaching two-degree warming, the UN's Intergovernmental Panel on Climate Change said in a report this year.
Explore further: Fingers pointed as climate talks deadlock