Countries from all over the world have reached an agreement on how to limit the effects of climate change in the future.
Leaders from 195 countries have been meeting in Peru, in South America, for two weeks.
They were trying to agree on plans and targets that each country would have to meet to reduce the amount of harmful gases it produces, and the amount energy it uses.
There were disagreements between richer and poorer countries at the summit about whether all nations should have the same targets.
Negotiators have now come up with a plan for countries to make their own pledges, which will be submitted at another conference next year.
Environmental groups have criticised the deal saying it weakens international climate rules.
United Nations members have reached an agreement on how countries should tackle climate change.
Delegates have approved a framework for setting national pledges to be submitted to a summit next year.
Differences over the draft text caused the talks in Lima, Peru, to overrun by two days.
Environmental groups have criticised the deal as a weak and ineffectual compromise, saying it weakens international climate rules.
The talks proved difficult because of divisions between rich and poor countries over how to spread the burden of pledges to cut carbon emissions.
'Not perfect'
The BBC's Matt McGrath in Lima says none of the 194 countries attending the talks walked away with everything they wanted, but everybody got something.
There was a great sense of relief among delegates when the announcement came in the early hours of Sunday morning, he adds, following 48 hours of talks without a break.
Peru's environment minister, Manuel Pulgar-Vidal, who chaired the summit, told reporters: "As a text it's not perfect, but it includes the positions of the parties."
The agreement was adopted hours after a previous draft was rejected by developing countries, who accused rich nations of shirking their responsibilities to fight global warming and pay for its impacts.
The final draft is said to have alleviated those concerns with by saying countries have "common but differentiated responsibilities".
The agreed document calls for:
- An "ambitious agreement" in 2015 that reflects "differentiated responsibilities and respective capabilities" of each nation
- Developed countries to provide financial support to "vulnerable" developing nations
- National pledges to be submitted by the first quarter of 2015 by those states "ready to do so"
- Countries to set targets that go beyond their "current undertaking"
- The UN climate change body to report back on the national pledges in November 2015
Environmental groups were scathing in their response to the document, saying the proposals were nowhere need drastic enough.
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."
Jagoda Munic, chairperson of Friends of the Earth International, said fears the talks would fail to deliver "a fair and ambitious outcome" had been proven "tragically accurate".
The talks followed last month's agreement on emissions targets between the US and China, but hopes it would encourage wider global agreement faded once talks began in Lima on 1 December.
On Saturday, US climate envoy Todd Stern had warned that the deadlock in the negotiations threatened the chances of a new global deal next year, saying it would be seen as "a major breakdown".
From CBBC newswround and BBC news