Chinese President Xi Jinping made his first trip to North Korea last week, marking the first time in 14 years that a Chinese head of state has made the trip. Xi previously had met with Kim Jong Un’s father, the late Kim Jong Il, in 2009. While China has historically been one of North Korea’s only and closest allies, notably coming to its aid during the Korean War, relations have not always been favorable.

Kim removed pro-Beijing government officials when he assumed power in 2011. After nearly a decade of pursuing nuclear weapons despite protests from Beijing, Kim set out to renew diplomatic relations in 2018, even taking an incredibly rare trip to China for a meeting with Xi.

Xi’s two day-long visit to North Korea came at an interesting time for both countries as they share a commonality of both coming under fire from the Trump administration. U.S. President Donald Trump famously engaged Kim in verbal sparring on Twitter, both during and after his campaign. Much like he has done with China, Trump has leveraged U.S. sanctions as a bargaining chip in the hopes of reaching an agreement. For North Korea, he’d like to see a complete abandonment of nuclear ambitions and for China, he has imposed sanctions in the pursuit of a better trade deal.

Both countries pose military problems for the U.S. and, in particular, its navy which patrols the South China Sea. The U.S. is also a staunch ally of South Korea with whom it has regularly held military exercises.

Together, Kim and Xi have found a shared international threat. China, however, sees itself as more of a mediator than ally in North Korean – U.S. disputes. It also has reason to believe that its technique is working – since it rekindled the relationship with its Asian neighbor, North Korea hasn’t performed any nuclear tests or fired long-range ballistic missiles.

Trump has responded favorably to that development and toned down his rhetoric against North Korea while also suspending the joint military exercises with South Korea.

Any discussion between Kim and Xi has likely involved economic issues which have a role in keeping the region stable. Beijing has historically been North Korea’s largest trading partner, although China has made moves in recent years that has slowed the North Korean economy. After the U.N. Security Council, of which China is a member, imposed sanctions following a 2017 North Korean nuclear test, trade reached record lows. Chinese banks also closed the account of Pyongyang’s primary exchange bank.

China continues to supply economic assistance to the impoverished nations, one of the last remaining cards Beijing could play if Kim’s nuclear aspirations were to resume.

For continuing to halt its nuclear program, China could provide even more financial and food assistance to North Korea, but Kim most certainly is trying to press Xi into lifting some of the U.N. sanctions. As a member of the security council, it would be within the realm of possibility for China to promote the idea, however it is unlikely.

Xi stands to gain the most from his state visit with Kim. Although on the surface it may have seemed as if North Korea’s economic plight was the issue, but in reality, it is China’s relationship with the U.S. that is at the heart of the visit. Xi and Trump will meet at the G20 summit in Japan at the end of this week and their trade war will be their main focal point. If Xi can bring progress with Kim to the table, it may help to win over Trump.

Few in Washington would expect China to be on its side and act in its interests, so Xi is probably counting on his mediation to be a welcome development. If he can succeed where Trump could not, the gap between Beijing and Washington might begin to close. Since he took office, Trump has held two summits with Kim but both have failed to deliver any solid progress.

Xi is running out of options when it comes to negotiating with Trump. Neither he nor his diplomats have made any headway with stopping Washington from imposing more sanctions and Trump has recently threatened to impose another round. Manufacturers for U.S. companies have begun to relocate to the Asian countries such as Vietnam to avoid the increased costs of exporting their goods.