Nearly 200 countries overcame political divisions late on Saturday to agree on rules for implementing a landmark global climate deal, but critics say it is not ambitious enough to prevent the dangerous effects of global warming.
After two weeks of talks in the Polish city of Katowice, nations finally reached consensus on a more detailed framework for the 2015 Paris Agreement, which aims to limit a rise in average world temperatures to "well below" 2 degrees Celsius (3.6 degrees Fahrenheit) above pre-industrial levels.
"It is not easy to find agreement on a deal so specific and technical. Through this package you have made a thousand little steps forward together. You can feel proud," Polish president of the talks Michal Kurtyka told delegates.
After he struck the gavel to signal agreement had been reached, ministers joined him on the stage, hugging and laughing in signs of relief after the marathon talks.
Before the talks started, many expected the deal would not be as robust as needed. The unity which underpinned the Paris talks has fragmented, and US President Donald Trump intends to pull his country - one of the world's biggest emitters - out of the pact.
At the 11th hour, ministers managed to break a deadlock between Brazil and other countries over the accounting rules for the monitoring of carbon credits, deferring the bulk of that discussion to next year, but missing an opportunity to send a signal to businesses to speed up their actions.
Still, exhausted ministers managed to bridge a series of divides to produce a 156-page rulebook - which is broken down into themes such as how countries will report and monitor their national pledges to curb greenhouse gas emissions and update their emissions plans.
Not everyone is happy with everything, but the process is still on track and it is something to build on, several ministers said.
"While some rulebook elements still need to be fleshed out, it is a foundation for strengthening the Paris Agreement and could help facilitate US re-entry into the Paris Agreement by a future presidential administration," said Alden Meyer of the Union of Concerned Scientists.
Some countries and green groups criticised the outcome for failing to urge increased ambitions on emissions cuts sufficiently to curb rising temperatures. Poorer nations vulnerable to climate change also wanted more clarity on how an already agreed $100 billion a year of climate finance by 2020 will be provided and on efforts to build on that amount further from the end of the decade.
A statement by UN Secretary-General António Guterres, who left the talks on Thursday, stressed the need for more work.
"From now on, my five priorities will be: ambition, ambition, ambition, ambition and ambition," it said.
"And ambition must guide all member states as they prepare their (emissions cut plans) for 2020 to reverse the present trend in which climate change is still running faster than us."
A UN-commissioned report by the IPCC in October warned that keeping the Earth's temperature rise to 1.5 degrees C would need "unprecedented changes" in every aspect of society.
Last week, Saudi Arabia, the Unites States, Russia and Kuwait refused to use the word "welcome" in association with the findings of the report.
The decision text now merely expresses gratitude for the work on the report, welcomes its timely completion and invites parties to use the information in it.
For many low-lying states and islands at risk from rising sea levels, this is not strong enough but had to be accepted grudgingly in exchange for other trade-offs.
During the two weeks of talks in Katowice - in the mining region of Silesia, a focus on the fossil fuel industry provided an unwelcome distraction for some countries and environmental groups which want to focus on cleaner energy.
The conference itself has been hosted by coal-reliant Poland, which has sought to protect its mining industry. The US administration's only event in Katowice was seen as trying to rebrand coal as a potentially clean energy source.