For years, the Obama administration prodded, cajoled and beseeched China to make commitments to limit the use of fossil fuels to try to slow the global effects of climate change.
President Barack Obama and other United States officials saw the pledges from both Beijing and Washington as crucial: China is the largest emitter of greenhouse gases, followed by the US.
In the coming years, the opposite dynamic is poised to play out. President Donald Trump's signing of an executive order on Tuesday, aimed at undoing many of the Obama administration's climate change policies, flips the roles of the two powers.
Now, it is far likelier that the world will see China pushing the US to meet its commitments and try to live up to the letter and spirit of the 2015 Paris Agreement, even if Mr Trump has signalled that he has no intention of doing so.
"They've set the direction they intend to go in the next five years," Ms Barbara Finamore, a senior lawyer and Asia director at the Natural Resources Defence Council, based in New York, said of China. "It's clear they intend to double down on bringing down their reliance on coal and increasing their use of renewable energy."
Referring to the economic development blueprints drawn up by the Chinese government, she added: "China wants to take over the role of the US as a climate leader, and they've baked it into their five-year plans."
Even before the presidential campaign last year, Mr Trump had made statements consistent with climate change denial, including calling climate change a hoax created by China. He has also threatened to formally withdraw the US from the Paris Agreement.
Since his election in November, senior Chinese officials and leaders have been taking the high ground on the issue by urging all countries, including the US, to abide by their climate commitments.
The biggest rhetorical turning point came in January, when China's President Xi Jinping said at the World Economic Forum in Davos, Switzerland, that the Paris Agreement was "hard won" and should remain in force.
"All signatories should stick to it instead of walking away from it, as this is a responsibility we must assume for future generations," he said.
Other Chinese officials at Davos repeated that message, including Energy Minister Nur Bekri, and top executives of state-owned enterprises.
In an interview before the recent climate conference in Marrakech, climate change researcher and policy adviser Chai Qimin said policies adopted at a recent Communist Party meeting showed that China "has attached ever greater importance to ecological civilisation and green development". He added: "Everyone is taking this more and more seriously."
On Wednesday, Global Times, a state-run newspaper, ran an editorial chastising the Trump administration for "brazenly shirking its responsibility on climate change". It added: "Washington is obliged to set an example for mankind's efforts against global warming, and now the Trump administration has become the first government of a major power to take opposite actions on the Paris Agreement... It is undermining the great cause of mankind trying to protect the earth, and the move is indeed irresponsible and very disappointing."
The editorial also questioned why China was making concessions on fossil fuel use when the US was scrapping its promises: "How can China, still underdeveloped, give away a chunk of room for development, just to nourish those Western countries that are already rich?"
Chinese participation is critical for global efforts on climate change. With its economic growth and rampant infrastructure construction, China consumes as much coal as the rest of the world combined.
The burning of coal, which is at the core of the power, steel and cement industries in the country, generates enormous amounts of carbon dioxide, the main greenhouse gas. So environmental advocates and officials around the world constantly say China must break its coal addiction.
But unlike in the US, Chinese leaders and senior officials have consistently said that climate change is a serious problem and acknowledged that changing the energy mix to move away from fossil fuel sources is important.
And because of its air pollution crisis, China announced policies in 2013 to limit the use of coal in the country's three largest population centres. More recently, scientists have said that there is a dangerous cycle at work: Weather patterns from climate change are exacerbating the smog.
"China is cutting back on coal because of its lethal costs to human health as well as its high carbon emissions, and plans to transition to the energy sources of tomorrow, rather than yesterday," said Ms Isabel Hilton, founder of Chinadialogue, a prominent website that reports on environmental issues and policy. "President Trump seems intent on reviving a 19th-century energy source rather than pursuing the promise of the 21st century."
Mr Trump's pro-coal talk, and the unlikelihood that his administration will pressure China to cut back on fossil fuels, might mean that pro-coal interests in China, including among state-owned energy companies, will try harder to push back against officials putting limits on coal.
But in recent years, coal consumption in China has declined slightly, surprising many analysts and researchers. China's economic slowdown - from decades of double-digit annual growth to 6.7 per cent last year - has been a major factor. Analysts say there appeared to be an increase in coal use during part of 2016 because of economic stimulus policies but preliminary statistics released in February indicate that overall coal consumption declined last year, compared with 2015.
Given such numbers, researchers say China may reach a carbon emissions peak in 2025 - five years ahead of its stated goal of 2030.
China has also made pledges on the percentage of total energy that will be generated by non-fossil fuel sources, which include wind, solar, hydro and nuclear power.
Mr Xi has said that by 2030, 20 per cent of China's energy will come from such sources, and officials are now grappling with the complex problem of getting energy generated by wind and solar sources onto the grid and used properly.
"Trump's rejection of regulatory action on climate change creates a vacuum in global climate leadership that China can now seize," said law professor Alex Wang, a China environmental expert at the University of California, Los Angeles. "In recent years, a variety of factors - crisis levels of pollution, economic opportunities from green development and concerns about the domestic risks of rising temperatures - have pushed China to action on climate change. Trump's actions don't affect these underlying drivers."
In addition, China has said it will put in place by the end of this year a national market for greenhouse gas quotas, commonly known as a cap-and-trade programme. It has experimented with seven such regional markets, and there have been problems with them, but the government is determined to set up a national programme to put a price on carbon and impose a cost on companies that generate large amounts of carbon dioxide, Chinese policy advisers say.
Beijing appears to be overperforming on other targets, besides its carbon emissions peak date. It had stated that by 2020, 58 per cent of its energy would come from coal consumption.
Official statistics indicate China might meet that target early. Chinese officials now say they expect to get the number down to 60 per cent this year.
A January report by the Ohio-based Institute for Energy Economics and Financial Analysis said China was the world leader in domestic investment in renewable energy and low-emissions energy sectors, with US$103 billion (S$144 billion) invested in 2015.
And China is going global with that strategy - last year, it invested US$32 billion in large overseas deals involving renewable energy.
"There are clear differences between the Chinese approach and the Trump administration on climate change," Ms Hilton said. "While Trump's administration seems to believe that action on climate change is a waste of money and threatens jobs in the US, China sees investment in climate-related action as essential to secure a safe and prosperous future for Chinese citizens, as well as a strategic opportunity to develop and supply the technologies of the future."
- Yufan Huang contributed research.