Copenhagen was a disaster. That much is agreed. But the truth about what actually happened is in danger of being lost amid the spin and inevitable mutual recriminations. The truth is this: China wrecked the talks, intentionally humiliated Barack Obama, and insisted on an awful "deal" so western leaders would walk away carrying the blame. How do I know this? Because I was in the room and saw it happen.

China's strategy was simple: block the open negotiations for two weeks, and then ensure that the closed-door deal made it look as if the west had failed the world's poor once again. And sure enough, the aid agencies, civil society movements and environmental groups all took the bait. The failure was "the inevitable result of rich countries refusing adequately and fairly to shoulder their overwhelming responsibility", said Christian Aid. "Rich countries have bullied developing nations," fumed Friends of the Earth International.

All very predictable, but the complete opposite of the truth. Even George Monbiot, writing in yesterday's Guardian, made the mistake of singly blaming Obama. But I saw Obama fighting desperately to salvage a deal, and the Chinese delegate saying "no", over and over again. Monbiot even approvingly quoted the Sudanese delegate Lumumba Di-Aping, who denounced the Copenhagen accord as "a suicide pact, an incineration pact, in order to maintain the economic dominance of a few countries".

Sudan behaves at the talks as a puppet of China; one of a number of countries that relieves the Chinese delegation of having to fight its battles in open sessions. It was a perfect stitch-up. China gutted the deal behind the scenes, and then left its proxies to savage it in public.

Here's what actually went on late last Friday night, as heads of state from two dozen countries met behind closed doors. Obama was at the table for several hours, sitting between Gordon Brown and the Ethiopian prime minister, Meles Zenawi. The Danish prime minister chaired, and on his right sat Ban Ki-moon, secretary-general of the UN. Probably only about 50 or 60 people, including the heads of state, were in the room. I was attached to one of the delegations, whose head of state was also present for most of the time.

What I saw was profoundly shocking. The Chinese premier, Wen Jinbao, did not deign to attend the meetings personally, instead sending a second-tier official in the country's foreign ministry to sit opposite Obama himself. The diplomatic snub was obvious and brutal, as was the practical implication: several times during the session, the world's most powerful heads of state were forced to wait around as the Chinese delegate went off to make telephone calls to his "superiors".

Shifting the blame

To those who would blame Obama and rich countries in general, know this: it was China's representative who insisted that industrialised country targets, previously agreed as an 80% cut by 2050, be taken out of the deal. "Why can't we even mention our own targets?" demanded a furious Angela Merkel. Australia's prime minister, Kevin Rudd, was annoyed enough to bang his microphone. Brazil's representative too pointed out the illogicality of China's position. Why should rich countries not announce even this unilateral cut? The Chinese delegate said no, and I watched, aghast, as Merkel threw up her hands in despair and conceded the point. Now we know why – because China bet, correctly, that Obama would get the blame for the Copenhagen accord's lack of ambition.

China, backed at times by India, then proceeded to take out all the numbers that mattered. A 2020 peaking year in global emissions, essential to restrain temperatures to 2C, was removed and replaced by woolly language suggesting that emissions should peak "as soon as possible". The long-term target, of global 50% cuts by 2050, was also excised. No one else, perhaps with the exceptions of India and Saudi Arabia, wanted this to happen. I am certain that had the Chinese not been in the room, we would have left Copenhagen with a deal that had environmentalists popping champagne corks popping in every corner of the world.

Strong position

So how did China manage to pull off this coup? First, it was in an extremely strong negotiating position. China didn't need a deal. As one developing country foreign minister said to me: "The Athenians had nothing to offer to the Spartans." On the other hand, western leaders in particular – but also presidents Lula of Brazil, Zuma of South Africa, Calderón of Mexico and many others – were desperate for a positive outcome. Obama needed a strong deal perhaps more than anyone. The US had confirmed the offer of $100bn to developing countries for adaptation, put serious cuts on the table for the first time (17% below 2005 levels by 2020), and was obviously prepared to up its offer.

Above all, Obama needed to be able to demonstrate to the Senate that he could deliver China in any global climate regulation framework, so conservative senators could not argue that US carbon cuts would further advantage Chinese industry. With midterm elections looming, Obama and his staff also knew that Copenhagen would be probably their only opportunity to go to climate change talks with a strong mandate. This further strengthened China's negotiating hand, as did the complete lack of civil society political pressure on either China or India. Campaign groups never blame developing countries for failure; this is an iron rule that is never broken. The Indians, in particular, have become past masters at co-opting the language of equity ("equal rights to the atmosphere") in the service of planetary suicide – and leftish campaigners and commentators are hoist with their own petard.

With the deal gutted, the heads of state session concluded with a final battle as the Chinese delegate insisted on removing the 1.5C target so beloved of the small island states and low-lying nations who have most to lose from rising seas. President Nasheed of the Maldives, supported by Brown, fought valiantly to save this crucial number. "How can you ask my country to go extinct?" demanded Nasheed. The Chinese delegate feigned great offence – and the number stayed, but surrounded by language which makes it all but meaningless. The deed was done.

China's game

All this raises the question: what is China's game? Why did China, in the words of a UK-based analyst who also spent hours in heads of state meetings, "not only reject targets for itself, but also refuse to allow any other country to take on binding targets?" The analyst, who has attended climate conferences for more than 15 years, concludes that China wants to weaken the climate regulation regime now "in order to avoid the risk that it might be called on to be more ambitious in a few years' time".

This does not mean China is not serious about global warming. It is strong in both the wind and solar industries. But China's growth, and growing global political and economic dominance, is based largely on cheap coal. China knows it is becoming an uncontested superpower; indeed its newfound muscular confidence was on striking display in Copenhagen. Its coal-based economy doubles every decade, and its power increases commensurately. Its leadership will not alter this magic formula unless they absolutely have to.

Copenhagen was much worse than just another bad deal, because it illustrated a profound shift in global geopolitics. This is fast becoming China's century, yet its leadership has displayed that multilateral environmental governance is not only not a priority, but is viewed as a hindrance to the new superpower's freedom of action. I left Copenhagen more despondent than I have felt in a long time. After all the hope and all the hype, the mobilisation of thousands, a wave of optimism crashed against the rock of global power politics, fell back, and drained away.