It took just a few hours for Donald Trump to upend a relationship that China had been cultivating for decades.

Only hours before he was seized in a nighttime raid, Venezuelan president Nicolás Maduro had been praising his Chinese counterpart Xi Jinping as an older brother with a powerful message as a leader to the world during a meeting with senior diplomats from Beijing.

China has invested heavily in oil-rich Venezuela, one of its closest South American partners. And its state media showed off the footage from that meeting to prove it: smiling men in suits, reviewing some of the 600 current agreements between their two countries - except the next photograph of Maduro was taken on board a US warship, blindfolded and handcuffed, in grey sweats.

China joined many countries around the world in condemning Washington's stunning move against a sovereign state. It accused the US of acting like a world judge and insisted that the sovereignty and security of all countries should be fully protected under international law.

Those stern words aside, Beijing will be making careful calculations not just to insure its foothold in South America, but also to manage an already tricky relationship with Trump and plot its next steps as the great power competition between the US and China takes a new, wholly unexpected turn.

Many see this as an opportunity for China's authoritarian Communist Party rulers. But there is also risk, uncertainty and frustration as Beijing tries to figure out what to do after Trump tore up the very international rulebook it has spent decades trying to play by.

Beijing, which likes to play the long game, is no fan of chaos. That is certainly what it seems to be coming up repeatedly against in Trump's second term. It had planned ahead and weathered the on-again, off-again trade war. Xi will believe he showed the US and the world just how dependent they are on Chinese manufacturing and technology.

But now Beijing faces a new challenge.

Trump's play for Venezuelan oil has likely strengthened China's deepest doubts about American intentions – how far would the US go to contain Chinese influence?

Speaking to NBC on Sunday, US Secretary of State Marco Rubio declared: This is the western hemisphere. This is where we live – and we're not going to allow the western hemisphere to be a base of operations for adversaries, competitors and rivals of the United States.

The not-so-hidden message was for Beijing: get out of our backyard.

Beijing is unlikely to listen. But it will wait to see what happens next.

Some wonder if China is waiting and watching to see if it could do the same in Taiwan, the self-governing island which it views as a breakaway province.

Xi has vowed that Taiwan will one day be reunified with the mainland and has not ruled out the use of force to achieve this. And some nationalists on Chinese social media are asking: if the US can unilaterally act in Caracas, what is stopping Beijing from snatching the Taiwanese president?

For one, Beijing might not see those parallels because it considers Taiwan an internal matter, and not a concern of the international order. But more importantly, if Xi decides to invade the island, it will not be because the US has set a precedent.

The relationship between Beijing and Caracas was fairly simple. China needed oil. Venezuela needed cash. From around 2000 to 2023 Beijing provided more than $100bn to Venezuela to finance railways, power plants and other infrastructure projects. In exchange, Caracas gave Beijing the oil it needed to fuel its booming economy.

Around 80% of Venezuelan oil was sent to China last year. That’s still only 4% of the country’s oil imports. So when it comes to China’s financial risks in Caracas, it’s important to keep some perspective, says Eric Olander, editor-in-chief of The China-Global South Project.

Chinese firms like CNPC and Sinopec are among the largest players there and there is a risk of those assets either being nationalised by the Venezuelans or otherwise marginalised amid the chaos.

But it could warn off future investors. Chinese enterprises need to fully assess the risks and extent of potential US intervention before investing in related projects, Cui Shoujun, from the School of International Relations at Renmin University, said on Chinese state media.

Beijing is likely to weigh the balance between maintaining its trade relations with the US while not wanting to lose its foothold in Latin America.

The concern for China is that other countries across South America start to worry about significant Chinese investments out of concern of attracting unwanted US attention.

China has shown patience and persistence in wooing South America. The Global South is a collective that often urges opposition to unilateral bullying by the U.S.

This situation presents a complex gamble for China that it usually avoids, especially given its investments and strategies in the region were built on a foundation of stability and long-term goals.