A historic, legally binding climate deal that aims to hold global temperatures to a maximum rise of 1.5C above pre-industrial levels, staving off the worst effects of catastrophic global warming, has been secured.
The culmination of more than 20 years of fraught UN climate talks has seen all countries agree to reduce emissions, promise to raise $100bn a year by 2020 to help poor countries adapt their economies, and accept a new goal of zero net emissions by later this century.
Formally adopted in Paris by 195 countries, the first universal climate deal will see an accelerated phase-out of fossil fuels, the growth of renewable energy streams and powerful new carbon markets to enable countries to trade emissions and protect forests.
As the final text of the agreement was released, the French president, François Hollande, said: "This is a major leap for mankind. The agreement will not be perfect for everyone, if everyone reads it with only their own interests in mind. We will not be judged on a clause in a sentence, but on the text as a whole. We will not be judged on a word, but on an act."
Economist Lord Stern added: "This is a historic moment, not just for us but for our children, our grandchildren and future generations. The Paris agreement is a turning point in the world's fight against unmanaged climate change which threatens prosperity. It creates enormous opportunities as countries begin to accelerate along the path towards low-carbon economic growth."
The British prime minister, David Cameron, also welcomed the deal, praising those involved for showing what ambition and perseverance could do. "We've secured our planet for many, many generations to come - and there is nothing more important than that," he said.
His energy and climate change secretary, Amber Rudd, told BBC One's The Andrew Marr Show that it did not always look like an agreement would be possible, but that the result was an "extraordinary achievement".
"It really went down to the wire with the final plenary meeting, it was suspended for an hour while final negotiations took place. And then we got it. But it's only the start. The French did a fantastic job managing the whole process, but - as they said themselves - it's a step in the right direction ... the work begins now.
"The current contributions that all countries are making actually takes us to [a] 2.7 [degree increase in global temperatures]," said Rudd. "So we need to do better than that, and what this did was set us on a pathway to try and achieve that.
"It is ambitious, but it is legally binding in some ways, and not in other ways. But we had to get the balance of being totally inclusive, getting 200 countries to sign up, but also not having such a tough compliance regime which you could say we had at Kyoto, which didn't succeed, that some countries would step away.
"I think this is the right balance. While it is a compromise, it is nevertheless an historic moment."
The US president, Barack Obama, said in a seven-minute address from the White House that the deal "shows what is possible when the world stands as one", and added: "This agreement represents the best chance we have to save the one planet that we've got."
But he went on to say the agreement "was not perfect. The problem's not solved because of this accord".
Climate scientists and activists cautioned that while the agreement was unexpectedly ambitious, the measures did not go far enough. "The cuts promised by countries are still insufficient, but the agreement sends a strong message to business, investors and cities that fossil fuels belong to the past," said Corinne Le Quere, director of the UK's Tyndall Centre for Climate Change Research.
Myles Allen, professor of geosystem science at Oxford, cast doubt on the 1.5C target: "Human-induced warming is already approaching one degree and is predicted to be at 1.2C by 2030, so 1.5C will be a challenge."
Bill McKibben, founder of environment movement 350.org, said: "The power of the fossil fuel industry is reflected in the text of the agreement, which drags out the transition [to clean energy] so far that endless climate damage will be done."
Kumi Naidoo, Greenpeace international director, added: "The deal puts the fossil fuel industry on the wrong side of history. But emission targets are not big enough. The nations that cause this problem have promised too little help to those people who are already losing their lives and livelihoods."
As tens of thousands of people demonstrated in the centre of Paris for a strong deal, the countries meeting at Le Bourget overcame historic differences in a series of all-night negotiations.
They were urged by the French foreign minister, Laurent Fabius, to compromise for the sake of humanity. "History is coming, in fact, history is here," he said.
"On 12 December 2015, we can have a historic day, a major date to go down in the history of mankind. The date can become a message of life. I am delighted, relieved, proud, that it will be launched from Paris, because Paris was attacked almost exactly a month ago."
The only previous UN climate agreement, the Kyoto protocol, required a number of rich countries to cut emissions marginally and was rejected by the US; the Paris deal applies to all nations. And while there will be no legal obligation for countries to cut emissions, the agreement includes a five-yearly global stocktake and a review mechanism to assess each country's contributions.
The last hours of negotiations were fraught as the French government sought to bridge yawning gaps between rich and poor countries.
"The outcome was a compromise that was hard to swallow for some countries but ultimately it had everyone's buy-in," said one Indian negotiator. "They [the French] talked to everyone. They got everyone on board. No party can say they have not contributed to this process. Everyone will have to swallow something. Everyone will lose something that is dear to them."
Despite the caveats, the agreement was broadly welcomed as a historic first step towards a decarbonised economy.
Ed Miliband vowed to use what he described as a "landmark" agreement to steamroll the government into being the first in the world to put a zero-carbon emissions target into law.
The former Labour leader said he would head a cross-party campaign to establish in British law a domestic goal of zero emissions at a point in this century.
He said: "I would say this is a landmark agreement and I think it will strengthen those that say Britain has to act, and will weaken those who say Britain should hang back, shouldn't go ahead.
"I think it will strengthen those who say that we need to up our ambition and I think it will strengthen the business voices as well that wanted certainty on a global level and are now arguing for it on a domestic level."
Jennifer Morgan of the Washington-based World Resources Institute said the long-term goal was "transformational" and sent signals to the heart of global financial markets.
Oxfam said the deal would be a landmark step but was not enough to ensure that a rise of 3C could be avoided or that sufficient climate funding had been secured for vulnerable communities.
Phil Jennings, the secretary general of the UNI global union, which has 20 million affiliated members in 140 countries, said: "The world now has a shared vision. Governments and investors around the world now understand that fossil fuels are no longer a safe option for the global economy and look forward to a future powered by renewables."
According to Kevin Watkins, executive director of the Overseas Development Institute: "More financial support is needed to ensure poor countries are not left paying the price of a climate crisis that is not of their making. This is a stronger agreement than expected; and governments around the world have demonstrated an understanding that we face a common threat and we are all in this together."