The crunch talks went late into the night as more than 190 countries attempted to agree on the best way to cut carbon emissions.
The last attempt to reach a global deal in Copenhagen at the end of last year ended in chaos and there were fears that the UN process could collapse completely if talks failed again.
However, after two weeks of negotiating, rich and poor countries agreed a compromise that will see all countries committed to cutting emissions for the first time.
The "Cancun package" also sets up a "green fund" to help poor countries cope with climate change and a new scheme to halt deforestation.
Cancun Climate Change Meeting Reaches Agreement
Bolivia claimed the agreement was "tantamount to genocide" because cuts are not tough enough to stop dangerous global warming.
But after repeated attempts to achieve consensus, the UN decision was taken without the agreement of the South American country.
To cheers from the ministers, Patricia Espinosa, Mexican foreign secretary and president of the talks, overruled the Bolivian negotiator who repeatedly took the floor and insisted the deal needed complete consensus.
"I of course note your position, but if there are no other objections, the document is adopted," she said to thunderous applause.
Felipe Calderón, the president of Mexico, said it was a historic agreement.
Cancun Climate Change Meeting Reaches Agreement
Comments