The world finally united behind a deal to tackle climate change on Saturday after a tense climax to the Cop26 summit.
The talks took an acrimonious last-minute twist as India pushed through an amendment on coal power, weakening the summit's calls to "consign coal to history".
Almost 200 countries signed off the compromise package despite many expressing doubts that it was equal to the challenge of global warming.
Known as the Glasgow Climate Pact, it emerged from frantic discussions after the summit stretched deep into overtime.
It opens the door to deeper emissions cuts by 2030 and greater financial firepower from rich nations to stave off a catastrophic cycle of floods, droughts and rising sea levels caused by climate change.
The amended text on fossil fuels, reluctantly agreed to by other parties to avoid sinking the deal, calls for a "phase-down of unabated coal", not a phase-out as originally envisaged.
Alok Sharma, the Cop26 president, appeared close to tears as he apologised for the way the late change had unfolded. "I also understand the deep disappointment," he said.
Some delegates said they were caught by surprise by India's gambit, which was supported by China. "This commitment on coal had been a bright spot in this package. It hurts deeply to see that bright spot dimmed," said a delegate from the Marshall Islands.
The pact reaffirms the goal of limiting global warming to 1.5°C above pre-industrial levels, although current pledges are not regarded as enough to achieve this. It follows an array of pledges made by smaller groups of countries during Cop26.
There was progress on a complex set of issues known as the Paris Rulebook which have been outstanding since 2015.
But the deal leaves out some other demands from campaigners and developing countries, such as a fund for compensating environmental damage.
"If it is a good negotiation, all the parties are uncomfortable," US envoy John Kerry told the UN summit.
Mr Sharma had to repeatedly delay the proceedings as delegates huddled on the floor of the conference.
He eventually won consensus for the deal hammered out in all-night negotiations amid tensions over fossil fuels, finance and carbon trading - but could not prevent the late change on coal.
“At the end of the day, what has been put forward here is a balanced package,” Mr Sharma said. “Everyone’s had a chance to have their say.
“I hope that colleagues will appreciate that what is on the table here, whilst not every aspect of it will be welcomed by everyone, collectively this is a package that really moves things for everyone.”
He said the 1.5°C target was still alive, but "its pulse is weak and it will only survive if we keep our promises and translate commitments into rapid action".
UN Secretary-General Antonio Guterres said "welcome steps" were taken at the summit but said the political will was lacking for a more ambitious deal.
"We are still knocking on the door of climate catastrophe," he said.
He called for an end to fossil fuels subsidies, a phase out of coal, a price on carbon, building resilience of vulnerable communities against the impacts of climate change and to make good on the long-promised $100 billion climate finance commitment to support developing countries.
He said: “We did not achieve these goals at this conference. But we have some building blocks for progress.”
UK Prime Minister Boris Johnson acknowledged there was a huge amount more to do in the coming years, but said: “Today’s agreement is a big step forward and, critically, we have the first ever international agreement to phase down coal and a road map to limit global warming to 1.5°C.”
Swedish environmental activist Greta Thunberg expressed her scepticism over the pact and said that Cop26 had achieved nothing but "blah, blah, blah".
"The real work continues outside these halls. And we will never give up, ever," the figurehead of the Fridays for Future movement posted on Twitter.
Taking the floor on the unscheduled 13th day of the summit, a number of countries signalled they were backing the deal despite misgivings.
A delegate from Guinea, speaking on behalf of a group of developing countries, said he could tolerate the wording despite "extreme disappointment" with parts of the text relating to environmental damage.
Countries promised merely a dialogue on the subject rather than the formal funding mechanism sought by some delegates.
“In the spirit of compromise, we will be able to able to live with this paragraph on the understanding that it does not reflect nor prejudge the unequivocal outcome that we seek on finance for loss and damage,” he said.
The Maldives, an island nation particularly vulnerable to rising sea levels, said it would support the "incremental progress" made by the deal but told Mr Sharma it was not enough to save its people.
“For some, loss and damage maybe the beginning of conversation and dialogue. But for us, this is a matter of survival,” said Environment Minister Shauna Aminath.
The US, EU, Brazil and Australia spoke in favour of the pact. But India paved the way for its last-minute change by telling the summit that developing countries were "entitled to the responsible use of fossil fuels".
It was the last in a series of changes to the contentious passage on fossil fuels. An appeal to move quickly away from coal power was earlier replaced with a call for “efforts towards” this.
Delegates added a further caveat that the “need for support towards a just transition” must be taken into account, addressing concerns over job losses.
But there was some optimism that the language on fossil fuels was retained at all. Camilla Born, an adviser to Mr Sharma, said it was the first time fossil fuels had been mentioned in a Cop's final text.
In another important area of the talks, the deal called on rich countries to double their funding for climate action by 2025.
It called on the UN to monitor progress on long-delayed promises of cash for developing nations who need money to face the impact of climate change.
The final text “notes with concern that the current provision of climate finance for adaptation remains insufficient to respond to worsening climate change impacts”.
The pact urged countries to revisit their 2030 climate targets by the end of next year to align with temperature goals set out in the Paris Agreement.
The aim of these is to limit global warming to below 2°C above pre-industrial levels, or ideally 1.5°C, to head off the most catastrophic effects of climate change.
Frans Timmermans, the EU’s top delegate in Glasgow, said the final text “allows us to act with the urgency that is essential for our survival”.
“Please embrace this text so that we can bring hope to the hearts of our children and grandchildren,” he said.
The summit began two weeks ago with dire warnings that humanity’s future was threatened if global warming was not kept in check.
Among the pledges agreed by smaller coalitions of countries during the summit were plans to reverse deforestation and reduce methane emissions.
Dozens of countries promised to turn their backs on coal power after Mr Sharma called for the summit to “consign coal to history”.
The US and China announced a surprise deal to co-operate on climate change, while India set its first ever target of net zero emissions for 2070.
Campaigners took a mixed view of the summit’s achievements, welcoming some progress while describing the overall picture as inadequate.
Gabriela Bucher, the head of Oxfam International, said big polluters should hear the call to strengthen their 2030 emissions targets.
“Despite years of talks, emissions continue to rise, and we are dangerously close to losing this race against time,” she said.
“The commitment to double [climate finance] is below what developing countries asked for and need, but if realised it will increase support to developing countries by billions.”
Jennifer Morgan, the executive director of Greenpeace, said the text was meek and the 1.5C goal “only just alive”.
But “a signal has been sent that the era of coal is ending… and that matters,” she said.