Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

The leader of China’s Communist Party lectured the American president-elect on Tuesday about the virtues of globalization, free trade and even green energy — a sign of just how much international politics has changed.

Chinese President Xi Jinping didn't need to mention Donald Trump during his speech at the World Economic Forum in Davos, Switzerland — several of his pointed remarks appeared unequivocally aimed at him.

With Trump defining his presidential campaign with his outspoken criticism of trade and immigration, the Chinese president appeared to be projecting his country as the world's new bastion of global capitalism.

China's President Xi Jinping attends the World Economic Forum in Davos, Switzerland, on Tuesday. Michel Euler / AP

"Pursuing protectionism is just like locking oneself in a dark room — while wind and rain may be kept outside, so are light and air," Xi told the audience, the first address by a Chinese leader at the annual event.

Trump has lambasted China for what he said were unfair trade practices, threatening to slap heavy tariffs on Beijing and label it a currency manipulator — something some experts have warned could spark a mutually destructive trade war.

China sold $423 billion of goods to the U.S. last year, $319 billion more than the U.S. exported in return. China also holds about $1.1 trillion in Treasury securities as of the end of December.

Trump told one rally in Indiana that "we can't continue to allow China to rape our country."

More recently, he called out China as one of the countries where America made "bad deals."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"We have hundreds of billions of dollars of losses on a yearly basis — hundreds of billions with China on trade and trade imbalance," Trump said Friday during his first press conference since being elected. "We don't make good deals anymore."

On Tuesday, Xi warned that "no one will emerge as a winner in a trade war," and urged the world not to blame globalization for all of its problems.

"Economic globalization used to be seen as the treasure cave found by Ali Baba in the Arabian Nights but now it has become the Pandora's Box in the eyes of many," he said. "The point I want to make is that many of the problems troubling the world are not caused by globalization."

Instead, Xi blamed "war, conflict and regional turbulence" — perhaps a dig at perceived U.S. foreign-policy failures in the Middle East — and said the solution lay in "making peace, promoting reconciliation and restoring stability."

Xi then appeared to turn his pulpit to Trump's stance on to global warming.

Trump has rejected the idea that humans are responsible for climate change, going against the consensus supported by the overwhelming majority of scientists.

He has called it a "hoax" several times, and even suggested in a 2012 tweet that it was a conspiracy invented by the Chinese, something he later said was a joke.

During his campaign, he threatened to pull out of the 2015 Paris Agreement, which was signed by almost 200 nations and aims to help the shift to renewable energy.

As the world's worst polluter since 2006, China has been far from blameless.

But it is also the leading producer in renewable energy sources, a move driven by financial pragmatism more than than global altruism, and it won plaudits last September after signing the Paris Agreement alongside the U.S.

In another apparent broadside at Trump, Xi said Tuesday that "all signatories should stick to it instead of walking away from it, as this is a responsibility we must assume for future generations."

Donald Trump appears on the front page of a Chinese newspaper in Beijing on Nov. 10, 2016. The headline reads "Outsider strikes back." Greg Baker / AFP/Getty Images

China has spent the past three decades transitioning from communism to a controlled-capitalist economy. Even so, the sight of a country still steeped in state ownership appearing to lecture the so-called leader of the free world on issues of global capitalism would have been a jarring sight for many.

Professor Steve Tsang, at the School of Oriental and African Studies, a London-based university, said Xi was only able to grab the opportunity because of the policies suggested by Trump.

"Xi gave that speech because Donald Trump gave him the opportunity to do it," according to Tsang. "Because most of the world is so unsatisfied with Trump, Xi is delivering what they want to hear."

Tsang also noted that Xi's comments can be read as a sign of how much China has been a beneficiary of globalization.

"What he is actually saying is not that different to what China has been doing for the past 25 years," he said.