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, others embraced.
"It's a victory for all of the planet and for future generations," U.S. Secretary of State John Kerry said, adding that the pact will "prevent the worst most devastating consequences of climate change from ever happening."
Brazilian Environment Minister Izabella Teixeira added: "Today, we've proven that it's possible for every country to come together, hand in hand, to do its part to fight climate change."
In the pact, the countries pledge to limit the amount of greenhouse gases emitted by human activity to the 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 - most of which come from the burning of oil, coal and gas for energy - 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, costly changes.
The deal now needs to be ratified by individual governments - at least 55 countries representing at least 55 percent of global emissions - before taking effect. 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.
"History will remember this day," U.N. Secretary General Ban Ki-moon said. "The Paris agreement on climate change is a monumental success for the planet and its people."
Speaking from Washington, President Barack Obama said the climate agreement offers "the best chance to save the one planet we have."
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 ready 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 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 pressed successfully to change the wording on emissions targets from saying developed countries "shall" commit to reducing emissions to they "should." Experts said that means the deal probably won't need U.S. congressional approval.
Nicaragua said it would not support the pact. Its envoy, Paul Oquist, said the agreement does not go far enough to cut global warming and help the poor countries affected by it.
Nicaragua is one of eight participating countries that haven't submitted emissions targets, after Venezuelan envoy Claudia Salerno said her country - which had been holding out - liked the agreement and had submitted its pledge.
Thousands of protesters demonstrated across Paris, saying the accord is too weak to save the planet. People held hands beneath the Eiffel Tower and stretched a two-kilometer-long (1.2-mile-long) banner from the Arc de Triomphe to the business district La Defense.
Kumi Naidoo of Greenpeace said the accord is 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."
The accord does represent 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 as unrealistic praised the final pact 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, Oppenheimer said, but added such technology would be expensive.
French President Francois Hollande welcomed the world to a "low carbon age," saying France is ready to cut emissions even further and increase aid to poor countries that are affected. He challenged all nations to do more.
"The 12th of December, 2015, will remain a great date for the planet," Hollande declared. "In Paris, there have been many revolutions over the centuries. Today it is the most beautiful and the most peaceful revolution that has just been accomplished - a revolution for climate change."