North Korean leader Kim Jong Un traveled to Beijing for a secret meeting with Chinese President Xi Jinping this week — marking the first time Kim has set foot outside North Korea since he took power in 2011.

The timing of this unprecedented meeting is no coincidence, taking place just weeks ahead of a possible summit between Kim and President Donald Trump to negotiate a curb on North Korea’s nuclear and missile programs.

Kim’s trip remains somewhat shrouded in mystery — the whole thing was incredibly cloak-and-dagger, even involving a mysterious green bulletproof train that Kim rode to and from Beijing — but Chinese state-run media said that Kim accepted an invitation from Xi for a face-to-face meeting to discuss the current nuclear standoff.

I reached out to Oriana Skylar Mastro, a China expert at Georgetown University and the conservative-leaning American Enterprise Institute, to try to get a better sense of why Kim agreed to meet with Xi, what China’s interests are in all of this, and what this meeting might portend for the possible upcoming Trump-Kim summit.

Mastro told me that Kim agreed to meet with Xi because he needed his support ahead of potential talks with Trump. She also said she thinks the meeting makes it more likely that a Trump-Kim summit will actually happen. “When Kim made the visit to Beijing, I realized Kim was serious about meeting with Trump because he knows he needs the Chinese on his side,” she told me.

A transcript of our conversation, lightly edited for length and clarity, follows.

Alex Ward

Why do you think President Xi Jinping wanted this meeting with Kim — and why now?

Oriana Skylar Mastro

China is probably concerned both about North Korea and the United States heading into the Trump-Kim talks, specifically that either side could make decisions that could precipitate a war.

For example, one of China’s concerns is that Trump and Kim could make some deal that Kim would inevitably break. Trump might then feel slighted, leading him to pursue a military option.

China also wants to gauge whether or not Kim is ready to talk in good faith. If he’s not, Beijing would want time to prepare the United States for that eventuality.

What I’m guessing happened in the meeting is that Xi chastised Kim for his nuclear and missile tests and made him promise not to do them again.

China probably also made other demands, like telling Kim to be more open to changes domestically. China also wants a say when it comes to North Korean policy, especially its economic policies. They no longer want to be notified after Kim makes a substantive policy decision. The Xi-Kim meeting is China inserting its influence in this process.

Alex Ward

On the flip side, why do you think Kim accepted the meeting with Xi?

Oriana Skylar Mastro

Kim probably realized that if he was going to meet directly with the United States, he needed Beijing’s support in that meeting to gain some sort of leverage in those discussions.

Alex Ward

So it seems like China and North Korea want to cooperate closely, but obviously China is the stronger power. How much influence does China really have over North Korea?

Oriana Skylar Mastro

There’s a difference between China being able to control how North Korea acts and China being able to drive the strategic situation so that it best suits its goals. Xi Jinping has been critical of Kim’s regime and had not met him before yesterday, but none of that really changed North Korea’s behavior.

I think what happened here is that the North Koreans came to the realization that the threats of a military strike were very real, and so they needed the Chinese help them do that fend off an attack.

Both countries are not very good at changing each other’s preferences, but they are very good at coordinating once they both want the same thing.

Alex Ward

It sounds like Kim wanted a meeting because he’s worried about possible US military strikes, and Xi wanted a meeting because he’s worried a failed summit could lead to US military action down the line. Was this Xi-Kim meeting born out of a fear of war?

Oriana Skylar Mastro

I think a fear of war and Kim’s desperation. Kim realized that US military options are more likely now than in the past, and that the Chinese were preparing for contingencies that did not involve supporting the North Korean regime.

If the US were to attack North Korea, China would intervene — not in support of North Korea, but rather in support of its own interests and would possibly even collaborate with the Americans. That would mean the end of Kim’s regime. So Kim had no other option but at least suggest that he was interested in denuclearization.

Alex Ward

Could a US military invasion of North Korea lead to a possible military conflict between the US and China?

Oriana Skylar Mastro

There’s no situation in which the United States beats China to North Korea — 85 percent of North Korea’s nuclear facilities are within 100 kilometers of the border with China. And the Chinese already have between 120,000 and 160,000 troops ready to go along the border.

China is going to get there first. So a conflict between China and the US depends on whether the US wants to militarily push China out — and I think that would be a very stupid move.

Alex Ward

Do you think China has felt sidelined in the current diplomatic process?

Oriana Skylar Mastro

China has for many years been arguing that the United States and North Korea should sit down with each other. China was therefore likely happy that Trump announced he was willing to talk to Kim. A reduction of tensions between North Korea and the US is better than the alternative.

All things being equal, though, China would like a seat at the table so they can make sure that neither side is making any promises or taking steps that hurt Beijing’s interests. Now, through this meeting with Kim, China gets some assurances of that.

“Kim had to show he realizes that he relies on China, that he will listen to China, and that he will respect China”

Alex Ward

How do you think China would react if there were a Trump-Kim deal? And how does China react if both sides fail to reach an agreement?

Oriana Skylar Mastro

China is going to hedge no matter what. If there is some sort of deal, the Chinese will think it buys them enough time until the end of this US administration, and will hope the next the one that follows has much more patience when dealing with North Korea.

But China will worry most of all that the US or North Korea will break any deal. Beijing would have to do some emergency diplomacy in that scenario.

Alex Ward

Why did Kim come to Beijing for the personal meeting with Xi? Wouldn’t a phone call have been good enough?

Oriana Skylar Mastro

From China’s perspective, a phone call would not do. Xi has despised Kim for years because he’s felt slighted and humiliated by this regime. There have been multiple times when China has publicly issued warnings to North Korea about not testing weapons, only for Pyongyang to go ahead and do it anyway.

On top of that, North Korea tested weaponry close to the Chinese border and on days that are important to China. For example, China was worried that Kim was planning a test during Beijing’s 18th Party Congress in 2012 just to spite China. The Chinese people are very sensitive to this, and there’s domestic political pressure to abandon North Korea.

So if Kim really wanted to make amends and ask China for help ahead of a meeting with Trump, a phone call was not going to be enough. Kim had to show he realizes that he relies on China, that he will listen to China, and that he will respect China.

Traveling to Beijing for the meeting makes Kim more credible than if he just picked up the phone and said, “Sorry for the past couple of years, I’m on board now.”

Alex Ward

So Kim’s meeting with Xi was more a less a mea culpa?

Oriana Skylar Mastro

That’s how I see it. Kim really had to make a public demonstration and show he’ll change his behavior.

Alex Ward

How does Xi’s meeting with Kim play domestically in China, then?

Oriana Skylar Mastro

Some in China feel that it looks bad to be associated with North Korea, and part of that comes from the perception that Pyongyang wasn’t respecting Beijing.

Kim attending the meeting may help assuage that perception. Now China can spin the meeting and claim it’s now a key mediator in the nuclear standoff. Xi already called Trump on Kim’s behalf to likely say, “The meeting went well; this is what Kim told me.”

Being seen as the go-to mediator is something the Chinese people like, and it could relieve some of Xi’s domestic political pressure.

Alex Ward

Will China’s mediation role lead to a positive outcome, do you think?

Oriana Skylar Mastro

China doesn’t have that much sway over North Korea, and Beijing wants to protect its own interests. The Chinese are not there to help the US, and we need to remember that as we head to the negotiating table.

But we have this tradition of thinking it’s better to do this in a multilateral format, maybe to keep the North Koreans from saying one thing to one party and another thing to another party.

Alex Ward

Do you think the Xi-Kim summit makes the Trump-Kim summit more or less likely to succeed?

Oriana Skylar Mastro

If anything, it makes the Trump-Kim summit more likely to happen. When Kim made the visit to Beijing, I realized Kim was serious about meeting with Trump because he knows he needs the Chinese on his side.

Alex Ward

Do you think Xi asked Kim if he was playing the United States?

Oriana Skylar Mastro

I don’t think Xi asked him — I think Xi told him not to talk with Trump just to stall for time to improve his intercontinental ballistic missiles.

Xi probably said something along the lines of “If you are stalling for time, the US might attack you and we will not defend you, and this will be the end of your regime.” I think Xi delivered more of a threat, and tried to gauge Kim’s reaction to see how serious he really is.

But the Chinese are not amateurs at this. They’ve dealt with North Korea for decades. I think Beijing has a healthy skepticism of what Kim’s ultimate goals are in these negotiations.

Alex Ward

So is China a friend or foe of the US when it comes to dealing with North Korea?

Oriana Skylar Mastro

It’s neither: China is more of a frenemy. The US has too many concerns and takes a big political risk if it deals with North Korea directly, so China is happy to be the mediator. But by being the mediator, China is going to make sure its interests are served first and above everyone else’s.

Maybe that’s a price the US is willing to pay, but it seems the administration doesn’t realize it will be paying that price.