The "Paris agreement" aims to keep global temperatures from rising another degree Celsius (1.8 Fahrenheit) between now and 2100, a key demand of poor countries ravaged by rising sea levels and other effects of climate change.
Loud applause erupted in the conference hall after French Foreign Minister Laurent Fabius gaveled the agreement. Some delegates wept and others embraced.
The agreement, South African Environment Minister Edna Molewa said, "can map a turning point to a better and safer world."
"This is huge," tweeted U.S. President Barack Obama. "Almost every country in the world just signed on to the #ParisAgreement on climate change - thanks to American leadership."
This is huge: Almost every country in the world just signed on to the #ParisAgreement on climate change—thanks to American leadership.— Barack Obama (@BarackObama) December 12, 2015
In the pact, the countries commit to limiting the amount of greenhouse gases emitted by human activity to the same levels that trees, soil and oceans can absorb naturally, beginning at some point between 2050 and 2100.
In practical terms, achieving that goal means the world would have to stop emitting greenhouse gases altogether in the next half-century, scientists said. That's because the less we pollute, the less pollution nature absorbs.
Achieving such a reduction in emissions would involve a complete transformation of how people get energy, and many activists worry that despite the pledges, countries are not ready to make such profound and costly changes.
The deal now needs to be ratified by individual governments - at least 55 countries representing at least 55 percent of global emissions - and would take effect in 2020. It is the first pact to ask all countries to join the fight against global warming, representing a sea change in U.N. talks that previously required only wealthy nations to reduce their emissions.
The deal commits countries to keeping the rise in global temperatures by the year 2100 compared with pre-industrial times "well below" 2 degrees Celsius (3.6 degrees Fahrenheit), and says they will "endeavor to limit" them even more, to 1.5 degrees Celsius. The world has already warmed by about 1 degree Celsius since pre-industrial times.
Ben Strauss, a sea level researcher at Climate Central, said limiting warming to 1.5 degrees instead of 2 degrees could potentially cut in half the projected 280 million people whose houses will eventually be submerged by rising seas.
More than 180 countries have already presented plans to limit greenhouse gas emissions- a breakthrough in itself after years of stalemate. But those pledges are not enough to achieve the goals in the accord, meaning countries will need to cut much more to meet the goal.
"We've agreed to what we ought to be doing, but no one yet has agreed to go do it," said Dennis Clare, a negotiator for the Federated States of Micronesia. "It's a whole lot of pomp, given the circumstances."
The agreement sets a goal of getting global greenhouse gas emissions to start falling "as soon as possible"; they have been generally rising since the industrial revolution.
It says wealthy nations should continue to provide financial support for poor nations to cope with climate change and encourages other countries to pitch in on a voluntary basis. That reflects Western attempts to expand the donor base to include advanced developing countries such as China.
In what would be a victory for small island nations, the agreement includes a section highlighting the losses they expect to incur from climate-related disasters that it's too late to adapt to. However, a footnote specifies that it "does not involve or provide any basis for any liability or compensation" - a key U.S. demand because it would let the Obama administration sign on to the deal without going through the Republican-led Senate.
The adoption of the agreement was held up for nearly two hours as the United States tried - successfully, in the end - to change the wording on emissions targets. The draft agreement had said developed countries "shall" commit to reducing emissions; in adopting the pact organizers changed the language to say those countries "should" make that commitment.
Experts said the deal probably won't need congressional approval.
Activists who say the agreement won't go far enough held protests across Paris on Saturday, calling attention to populations threatened by melting glaciers, rising seas and expanding deserts.
Kumi Naidoo of Greenpeace praised the accord was a good start but isn't enough.
"Today the human race has joined in a common cause, but it's what happens after this conference that really matters," he said. "This deal alone won't dig us out the hole we're in, but it makes the sides less steep."
Still, the accord is a breakthrough in climate negotiations. The U.N. has been working for more than two decades to persuade governments to work together to reduce the man-made emissions that scientists say are warming the planet.
The previous emissions treaty, the 1997 Kyoto Protocol, included only rich countries and the U.S. never signed on. The last climate summit, in Copenhagen in 2009, ended in failure when countries couldn't agree on a binding emissions pact.
The talks were initially scheduled to end Friday but ran over as Western powers, tiny Pacific island nations and everyone in between haggled over wording.
The main dispute centered over how to anchor the climate targets in a binding international pact, with China and other major developing countries insisting on different rules for rich and poor nations. The agreement struck a middle ground, removing a strict firewall between rich and poor nations and saying that expectations on countries to take climate action should grow as their capabilities evolve. It does not require them to do so.
Some scientists who had criticized earlier drafts of the pact as unrealistic praised the final language for including language that essentially means the world will have to all but stop polluting with greenhouse gases by 2070 to reach the 2-degree goal, or by 2050 to reach the 1.5-degree goal.
That's because when emissions fall, nature compensates by absorbing less carbon dioxide - and can even release old pollution once there's less of it in the air, said Princeton University's Michael Oppenheimer. Forests, oceans and soil currently absorb about half the world's man-made carbon dioxide emissions.
"It means that in the end, you have to phase out carbon dioxide," said John Schellnhuber, director of the Potsdam Institute for Climate Impact Research in Germany.
In addition to the cuts in emissions, the goal could be reached in part by increasing how much carbon dioxide is sucked out of the air by planting forests or with futuristic technology, said Princeton University's Michael Oppenheimer. But, he added, such technology would be expensive and might not come about.