South Korea’s political crisis shows no sign of abating. President Yoon Suk Yeol’s impeachment and impending arrest will usher in months of leadership uncertainty. The chaos will be welcomed by China and North Korea, but for the U.S., its influence with a key ally is at risk.

Yoon has said he will fight to stay on, despite his disastrous declaration of martial law late on Dec. 3, but he is unlikely to succeed. The Constitutional Court has 180 days to decide whether to accept the impeachment motion passed by the National Assembly as legal. If it does, the leader will be ousted and elections must be held in 60 days.

His loss will be destabilizing for the U.S. Yoon was a key driver in the South Korea, Japan and U.S. trilateral alliance, designed to boost regional security in the face of China’s expansionism and North Korea’s belligerence. Joint U.S.-Korea training on submarine hunting and sharing real-time data on ballistic missile launches to ward off potential threats from Pyongyang were among his biggest achievements.

But now all three architects of that plan — Yoon, U.S. President Joe Biden and former Japanese Prime Minister Fumio Kishida — are either out of office, or on their way out. For Beijing and Pyongyang, this moment fundamentally changes the geopolitical landscape to one that is far less hostile.

Both will now have the opportunity to create an atmosphere more conducive to their political aims. In China’s case, a South Korea that’s less susceptible to American influence helps to tilt the balance in the Indo-Pacific in Beijing’s favor. For North Korea, a distracted Seoul means it can continue to build closer ties with Russia and expand its nuclear weapons program undisturbed.

The first gift may come in the form of a new South Korean president. The most promising candidate is opposition leader Lee Jae-myung, often described as the nation’s Bernie Sanders or Donald Trump for his populist style. The 61-year old politician favors China policies that are closer to what Beijing would like to see. Lee has refused to take sides in the rivalry, opting for strategic balance rather than leaning toward Washington as Yoon did.

He’s also been an outspoken critic of the THAAD missile — an acronym for the Lockheed Martin-made Terminal High Altitude Area Defense system, which is designed to destroy short-and-medium-ranged ballistic missiles at high altitudes as they descend. THAAD would protect South Korea from the North’s missiles, but Beijing sees it as another example of American power in its backyard.

When first installed in South Korea by the U.S. military in 2016, THAAD triggered massive economic boycotts of South Korean goods by Chinese consumers, prompting previous president Moon Jae-in to halt deployment. It has remained as a 'temporary' installation due to fierce backlash from China, although Yoon — who was an ardent champion of THAAD — has said it is necessary for self-defense. Lee has talked about the importance of "pragmatic diplomacy,” calling China a vital strategic partner. Reversing course on the missile defense system would please Beijing.

For North Korea’s Kim Jong Un, the possibility of a change in leadership next door is also a moment to be exploited, particularly as Donald Trump will soon be back in the White House and he’s expected to be less friendly this time round.

Kim will be looking to take advantage of any new cracks in the Seoul-Washington relationship. The last time Trump was in power, the U.S. leader put an end to large-scale military training drills with Seoul in an effort to bring Kim to the negotiating table and stop his nuclear weapons program. Those drills were restarted and expanded under the Biden administration. Trump may offer to suspend them again as an incentive to get Kim to make a deal.

With Seoul preoccupied with political crisis, Kim will be able to strengthen his relationship with Moscow undeterred, as Gabriela Bernal notes for the Sydney-based Lowy Institute think tank. Both North Korea and Russia may seek to exploit the situation and double down on military collaboration with little fear of South Korean intervention. The news that several hundred North Korean soldiers have died fighting on Moscow’s behalf, is unlikely to prevent further cooperation.

The Biden administration has worked hard to shore up alliances between Seoul and Tokyo, putting significant effort into ensuring that both sides put away their historical acrimony. Trump has not typically been deft enough to manage these tensions with the subtlety required to handle such brittle relationships.

A priority for Trump’s national security team should be maintaining American power and presence in the region. Building a strong relationship with the next South Korean leader will be key to achieving that.

Karishma Vaswani is a Bloomberg Opinion columnist covering Asia politics with a special focus on China.