It was very nearly a diplomatic disaster.
Alok Sharma, the president of the UN climate conference in Scotland, had convened the final meeting of representatives from nearly 200 countries to deliver the Glasgow Climate Pact, a deal meant to ensure the world still has a chance to avert the worst impacts of global warming.
It was moment born of weeks of arduous negotiation and months of painstaking preparations. Delegates in the plenary hall at COP26 were taking pictures to mark the historic moment.
But as envoys prepared to take their seats to adopt the accord on Saturday night, an unresolved dispute over coal threatened to derail it, and most of the people in the room had no idea.
China, India, and other developing nations rich in coal reserves were threatening to scupper the deal over language that asked governments to “phase out” their use of coal, a demand they considered unfair and damaging to their hopes of economic growth.
Also read: Thunberg denounces COP26 deal, UN chief warns 'catastrophe' close
US special climate envoy John Kerry had been working the room and caught wind of the issue while chatting with his Chinese counterpart Xie Zhenhua. Days earlier the two men had boosted morale at the summit by unveiling a surprise joint declaration in which Beijing promised to ramp up its ambition to cut emissions.
“You’re supposed to be phasing out coal over the next 20 years, you just signed an agreement with us,” Kerry told Xie as they stood together in the buzzing plenary hall.
Xie, through his translator responded: "We said phase down."
Moments later, as other country delegations milled about waiting for the plenary to open, Kerry, Xie, and their counterparts from the European Union and India left the room to meet privately. They came out of their meeting about 30 minutes later.
When Xie returned he told a Reuters reporter that “we have a deal” and gave a thumbs up.
That deal was introduced to the room awkwardly.
As Sharma finally opened the meeting and began the process of adopting the accord, China and India intervened. It was India that laid out their last-minute proposal: The coal “phase out” would become a “phase down”, said Environment Minister Bhupender Yadav.
Sharma, standing at the podium, looked as though he was about to cry. He apologized to the plenary, and then asked if the proposal was acceptable.
Also read: COP26 comes to an end with ‘imperfect compromise’ in Glasgow
Despite withering criticism from nations ranging from Switzerland to Mexico, who were concerned a "phase down" would open the door to endless coal use, none were willing to leave Glasgow without a deal. And so it passed.
The dissatisfied envoys were allowed to speak. Then Sharma asked the plenary to support passage of the deal, and with no delegates formally objecting, he tapped his gavel to indicate it had passed.
Asked about getting emotional on stage, Sharma later told reporters: "I've had about six hours sleep in the last three days. But you know, look, it is emotional, in the sense that collectively, as a team, we have achieved what I suspect, very many people doubted."
In an accord already jammed with compromises, this was just one more.
For Kerry, who helped to broker it, it was the one that held the Glasgow Climate Pact together. "If we hadn’t done that we wouldn’t have an agreement,” he told reporters.