President Trump’s decision to withdraw from the Paris climate agreement caused anger and anxiety across the world, with one major exception: China.

With the US stepping away from its role as a leader of the global fight against climate change, Beijing is already moving to fill the void, giving it a chance to benefit both diplomatically and economically.

It isn’t the first time Trump — who spent the campaign demonizing China — will have wound up giving Beijing a major chance to expand its standing on the world stage.

After Trump withdrew the US from the Trans-Pacific Partnership, China inserted itself into trade talks among other nations disappointed by America’s reversal. As Canada and Mexico have felt spurned by Trump during the runup to renegotiating NAFTA, China has emerged as a more reliable trading prospect.

This isn’t happening quietly behind the scenes: At China’s first appearance at the World Economic Forum in Davos, Chinese President Xi Jinping chided the West for its flirtation with protectionism, and painted a picture of his country as a paragon of free trade and an inviting place for foreign investment.

Now, as the US pulls out of the global community’s effort to curb carbon emissions, China’s profile as a forward-looking world leader will only grow. It’s set to become closer to the US’s allies that feel abandoned by Trump’s recent actions, as well as take a more aggressive lead in building a green economy.

“While the US is breaking these ties, China — which has traditionally been more reserved in international affairs — is building them at breakneck pace,” Alex Wang, an environmental law professor at the University of California Los Angeles, told me. “As the US loses good will, China is building it.”

China is set to grow much closer to Europe

The reshuffling of the world order in the wake of Trump’s announcement could be seen almost immediately, with top Chinese and European leaders criticizing the US’s withdrawal side by side on Thursday.

Standing next to German Chancellor Angela Merkel, Chinese Premier Li Keqiang said that “fighting climate change is a global consensus” and pledged that China would remain committed to the Paris agreement.

Merkel said "the cooperation of the European Union with China in this area will play a crucial role, especially in regards to new technologies."

In a statement to the press, Miguel Arias Cañete, the European Union commissioner on climate action and energy, made the point even more forcefully: "No one should be left behind, but the EU and China have decided to move forward. Our successful cooperation on issues like emissions trading and clean technologies are bearing fruit. Now is the time to further strengthen these ties to keep the wheels turning for ambitious global climate action.”

It won’t be the last time that Beijing and Brussels find themselves seeing eye to eye, or that the two sides look past the US and look to work on joint initiatives that don’t involve Washington. And Europe and China’s enhanced cooperation is quite likely to go beyond coordinating on climate change.

“These agreements ... build ties and align interests in ways that reduce the likelihood of conflict and bolster the opportunities for greater growth and development,” Wang says.

To make that a little more concrete, let’s take something like China’s jaw-droppingly ambitious One Belt, One Road initiative. It’s a Chinese-funded infrastructure project designed to connect China to 64 countries in Asia, Europe, the Middle East, and Africa that make up around 60 percent of the world’s population.

As is often the case with countries that deal with trading with China, Europe has expressed concern about China’s compliance with global trade norms as Beijing goes about pitching its proposals for trains and tunnels. Those are big issues that aren’t easy to surmount, but they become a little bit easier to deal with when you’re able to build goodwill through cooperation on issues like climate change.

“As the US loses goodwill, China is building it” —Alex Wang

If Europe and China are actually able to grow closer through their coordination on climate change, it could potentially build a better relationship for navigating conflicts over trade.

In the meantime, the US and Europe are going through the roughest patch they’ve had since they split over the Iraq War in 2003. Even before Trump pulled out of the Paris agreement on Thursday, he had already alienated Europe during his trip abroad last week, when he, among other things, refused to reaffirm America’s commitment to NATO and accused Germany of being a trade cheat.

Trump’s America First agenda has been a huge gift to China

But the impact of Trump’s withdrawal from the world stage is bigger than China’s relationship with Europe.

Consider how, on his first full working day as president, he withdrew from the Trans-Pacific Partnership, an agreement that would’ve boosted trade ties between the US and 11 countries along the Pacific Rim and generated the largest trade bloc the world had ever seen.

The accord would have strengthened ties between the US and a number of China’s neighbors and would’ve served as a counterweight to Beijing’s increasing influence in the region (China wasn't part of the deal).

Now, Trump’s move means that Beijing has a major opportunity to step into that vacuum and negotiate a regional trade deal that basically serves as a China-centric version of the TPP. It’s already been making efforts to do exactly that.

China has generally been eager to capitalize on Trump’s protectionist tendencies. In his World Economic Forum speech, Chinese President Xi warned against rising nationalism in the West and defended free trade. This is China lecturing the US and Europe about free trade. China’s economy has liberalized significantly in recent decades, but it’s a country that flagrantly disregards all kinds of global trade rules, from denying market access to foreign companies to subsidizing many of its key industries. But when you have the most powerful politician in the world calling for 45 percent tariffs against other countries, Xi doesn’t look so preposterous.

If there’s one realm where China is set to best the US in the wake of Paris, it’s in developing a sustainable economy. It’s already investing more than the US in clean energy — in 2016, it invested more than $88 billion to the US’s $59 billion — but the gulf between the US and China will grow as the US decides that renewable energy investment isn’t a priority. And it will grow fast. America First is turning out to be anything but.