A visit to Beijing by Kerry and a missive from Obama were key moments in a nine-month negotiation between the world’s biggest polluters

The climate deal announced on Wednesday between the world’s two biggest carbon polluters was struck after a personal letter from Barack Obama, and nine months of intensive diplomacy. But American and Chinese officials had been in search of an agreement – through official meetings and back-channel negotiations – since the days when George Bush was president.

The plan unveiled in Beijing by Obama and his Chinese counterpart, Xi Jinping, commits the two countries to ambitious cuts to greenhouse gas emissions after 2020, and could spur other big polluters to similar efforts.

After years of mistrust, the deal began to coalesce last spring after Obama sent a personal letter to Xi suggesting the two countries start to move in tandem to cut carbon pollution, the White House said.

The immediate inspiration for the letter arose from a visit to Beijing by John Kerry, the US secretary of state. Kerry, who had a strong environmental record when he was a senator, raised climate change to a top priority after taking over at State. He floated the idea of setting joint targets in his meetings with Chinese officials, a senior administration official said.

“The idea was first hatched in a bilateral visit that Secretary Kerry had in early February, where he broached it with the Chinese,” the official said. “And when the Chinese side seemed potentially receptive, we followed up with that letter from President Obama to President Xi.”

What came next was a flurry of diplomatic meetings – including a pivotal encounter on the sidelines of the United Nations climate summit in September between Obama and the Chinese vice-premier Zhang Gaoli, who has charge of climate and energy.

At the time, there was speculation that China would use the spotlight of the UN summit to announce a date for peaking emissions. That did not materialise.

The timing was too close to the midterm elections and China was adamant about making the historic announcement from home turf, those who have followed the talks closely said.

But the White House said Zhang did tell Obama during a meeting that China wanted to move ahead quickly on a separate climate deal.

“The message from Vice-Premier Zhang Gaoli was that President Xi was interested in taking the president’s offer up and moving forward with this announcement when we were in Beijing,” the official said.

A number of US officials were dispatched to Beijing, including the senior White House adviser on climate policy, John Podesta, and the State Department climate change envoy, Todd Stern, the White House said.

By early November, officials were parsing the language of an eventual announcement – a process that evidently went down to the wire, in the official’s account.

“We were here the week before last and had intensive discussions about what our respective targets would look like, and then finally were able to negotiate a text which was finalised late yesterday.”

By the time it reached that crunch point, however, US and Chinese officials had spent the better part of two years trying to overcome their mutual suspicion – and nearly a decade in on-off negotiations for a two-way climate deal.

After the disaster of the Copenhagen climate summit in 2009, when Obama was on the receiving end of a pointed diplomatic snub from Chinese officials, the two countries began to put in the hard work needed to repair the relationship.

As those familiar with United Nations climate negotiations recognised, there was no other way. China and America between them are responsible for 42% of global greenhouse gas emissions, according to the US EIA’s 2012 data.

Unless they were serious about cutting carbon pollution, there was no hope of fighting climate change.

The primacy of the US-Chinese relationship was familiar to a number of highly placed officials in the Obama administration.

Beginning in late 2007, when George Bush was president, a group of leading Republicans and Democrats led two secretive missions to China to try to secure a bilateral climate agreement.

The initiative included John Holdren, now the White House science adviser, and culminated in a meeting at a luxury hotel at the Great Wall of China in July 2008.

It also produced a draft agreement in March 2009, two months after Obama took office, but it was never signed. Obama’s hopes of passing a climate law died in Congress.

After his re-election, however, Obama recommitted to fighting climate change, and again took up pursuit of the China deal.

“At the beginning of the second term the president recognised that he had to both take domestic action to have credibility but also to begin bilateral negotiations with China to actually bend down the global emissions curve,” said Paul Bledsoe, a climate change official under Bill Clinton. “From the moment of his re-election, this process began. This is essentially the culmination of two years of effort, recognising that until Chinese emissions begin to decline, global emissions cannot decline. That is just the reality of the problem.”

On the diplomatic track, US and Chinese officials were signing agreements to work together on developing technologies for the smart grid, cleaner vehicles and energy-saving buildings.

The trust-building exercises paid off. In June 2013 Obama and Xi reached an agreement to phase out the super-pollutant HFCs – an extremely potent greenhouse gas used in air conditioners and refrigerators. Industrialised countries adopted the agreement a few months later.

Obama, meanwhile, began assembling evidence that he was serious about cutting greenhouse gas emissions at home – and not just demanding such actions from other countries.

Shortly after the HFC deal, Obama unveiled his signature plan to cut carbon dioxide emissions from power plants, the single biggest source of carbon pollution.

China also began to put its own house in order, spurred in part by deadly air pollution levels from coal-fired power plants. In 2011, the Chinese government for the first time set targets for a less polluting course of growth, and began rolling out new solar and wind plants. Seven regions introduced carbon trading schemes.

By the beginning of this year, all the pieces were beginning to fall into place. It had been, in Bledsoe’s view, the work of a decade. “Todd [Stern] and Podesta and Holdren were all working on these issues in the late 1990s,” he said.

“Until about two or three years ago there was still a broader focus on the UN negotiations rather than the bilateral relationship with China as the sine qua non of climate protection. That is what changed after the re-election: the recognition that this was essentially the only game in town.”