On Thursday, US President Donald Trump handed China the keys and an extra tank of gas -- quitting the Paris climate accord and shifting leadership of global efforts to limit climate change to Asia.

"If you're Xi Jinping, you probably could not have written a better script for how this year could go with Trump essentially retreating across the board on these issues," says Christopher Balding, a professor of economics at Peking University.

"When there's a vacuum, China will step forward and take that."

Read More

Even before Trump went public with his decision to ditch the agreement, China, the world's second largest economy, made clear it would stick with the Paris accord while Premier Li Keqiang met with European leaders, including German Chancellor Angela Merkel, this week.

China reaffirmed its commitment to fighting climate change, saying it was a "responsibility shouldered by China as a responsible major country."

"We think the Paris accord reflects the widest agreement of the international community with regards to climate change, and parties should cherish this hard-won outcome," said foreign ministry spokeswoman Hua Chunying, Friday.

From climate bad boy to champion?

China's hasn't always been a leading voice in the fight against climate change. In 2009, at the Copenhagen climate talks, the country was accused of dragging its feet. Li Shuo, a climate analyst at Greenpeace in Beijing, said China was once considered a "climate bad boy."

Three things have changed since then, says Balding. First, reducing pollution has become an important issue domestically -- especially among the growing middle class. Second, China scented economic opportunity in clean energy and pumped money into the sector.

Third, says Balding: "Scientists in China were very diligent and they said look, climate change isn't just some Western conspiracy to keep China down. There's valid evidence."

China has made strides in cutting emissions and promoting investment in renewable energy but the switch away from coal has been slow --it still accounts for 66% of its energy mix.

The country's National Energy Administration said in January that China will spend more than $360 billion through 2020 on renewable technologies such as solar and wind.

China invested more than $88 billion in clean energy in 2016, according to Bloomberg New Energy Finance, down from an all time high of almost $120 billion in 2015, but still significantly more than the $58.8 billion invested by the US last year.

"I'm hesitant to call it a true leader on climate change but it is a de facto leader. This has fallen into its lap," Balding said.

The moral victory that the US has ceded to China gives Xi a boost at home as well as on the global stage.

China will have its once-every-five years Communist Party National Congress later this year when a new generation of leaders will be revealed -- akin to an election year in the US, says Balding.

"Being able to say that China is more important globally than it was five years ago, that builds morale going into the Fall," he says.

Europe hedging its bets

The reputational and geopolitical blow that Trump has dealt to the United States was clearly on view this week in Europe, says Li from Greenpeace.

But for all their new found passion, China and Europe make uneasy bedfellows. There are major questions about the compatibility of their economic systems plus flashpoints over democracy and human rights.

"I think Europe is frustrated with Trump and they want to do business with China and have it on board with climate change but there are big differences in values," says a Beijing professor, who didn't want to be identified speaking on what he described as a sensitive topic.

The professor says Trump's turn inward tarnishes the democratic model the US has sought to project elsewhere -- at least from outside the Western world.

"Democracy, at least how its practiced, seems to be underperforming in many areas right now and it's facing harsh criticism. The reputation of China and the China model rises because of this."

CNN's Serenitie Wang, Nanlin Fang and James Griffiths contributed to this report