This week, Kim Jong Un made yet another surprise trip to China, his third in as many months. At the Great Hall of the People in Beijing, Kim and Chinese President Xi Jinping allegedly discussed denuclearization and other issues.

The visit came just days after Kim met with President Trump in Singapore, and it highlights the importance of the China-North Korea relationship. As my colleague Emily Rauhala put it: "The timing and staging of Kim’s trip sends a clear message about Beijing’s place at the center of East Asian diplomacy — and its power over Pyongyang."

China is North Korea's main trading partner and its key ally in international negotiations. That support, however, has its limits. China has sought (unsuccessfully) to keep Pyongyang from developing nuclear weapons, supporting tough sanctions when necessary. Kim, meanwhile, has sometimes lashed out against Beijing in an effort to prove his independence. Last year, an article in the country's state news outlet attacked China directly for condemning North Korea's nuclear program. "A string of absurd and reckless remarks are now heard from China every day only to render the present bad situation tenser," it read.

For Kim, setting up talks with South Korea and the United States may have partly been about asserting that independence. As the Guardian puts it: "North Korea needs China’s food and energy, but chafes at its subordinate position, and has long sought direct talks with the U.S. Winning those gives Kim the chance to rebalance relations with China."

But no long-term agreement on North Korea's nuclear weapons will be achieved without buy-in from both Xi and Kim. Here's a look at how the relationship developed and what it means for the rest of the world.

What's the history of the relationship between China and North Korea?  

China's complicated friendship with North Korea dates back to World War II. At the end of the war, the Allies decided to divide the Korea Peninsula along the 38th parallel. The north would be occupied by the Soviet Union, the south by the United States.

An uneasy peace held until North Korea invaded South Korea in 1950. United Nations troops — mainly Americans — were sent to defend the South, and Chinese forces later joined the war to defend the North. After three bloody years, the two sides signed an armistice that is still in effect — there is de facto peace, but the war never officially ended. Any effort to sign a formal peace treaty (widely considered one of the first steps toward reunifying the Koreas) would have to be approved by China, one of the signatories to the armistice.

Since the Korean War, China has offered economic and political backing to North Korea's leaders. But that unyielding support began to waver in 2006, when North Korea launched its first nuclear-weapons test. Beijing sharply rebuked its ally and has expressed "grave concern and opposition" to North Korea's pursuit of nuclear weapons and called on Pyongyang to stop antagonizing South Korea.

What does North Korea get out of its relationship with China?

China is North Korea's most important trading partner. Between 2000 and 2016, trade between the two countries jumped tenfold, peaking at $6.86 billion in 2014. By some estimates, China is responsible for more than 90 percent of North Korea's trade. China also provides direct aid in the form of food and energy.

What about China? Why does Beijing care about propping up Kim?

For one, the country provides China important strategic protections. It serves as a buffer between China and South Korea, a key U.S. ally, and the 29,000 members of the U.S. military stationed there.

China also fears what might happen if North Korea's government collapsed. Hundreds of thousands of refugees would likely flow across the 870-mile-long border between the countries, creating a massive migrant crisis. "While the Chinese certainly would prefer that North Korea not have nuclear weapons, their greatest fear is regime collapse," wrote Jennifer Lind, a professor at Dartmouth College, in an essay for CNN.

As Brookings put it, "China has regarded stability on the Korean Peninsula as its primary interest."

Why have China and North Korea clashed?

China has been vocally opposed to North Korea's efforts to develop nuclear weapons, worried that its program could lead to an arms race in the region. Xi and his allies also worry that North Korea's nukes might prompt an intervention by the United States, which would destabilize the regime.

Beijing also wants to avoid getting into another war on Pyongyang's behalf. The 1961 Sino-North Korea Treaty of Friendship, Cooperation and Mutual Assistance obliges China to intervene in case of "unprovoked aggression" against the North — though Beijing has said it might not honor that accord.

What has China done internationally?

At times, China has been willing to join the international community to put the squeeze on North Korea, particularly when it comes to stemming the country's nuclear program.

In Oct. 2006, when Pyongyang tested a nuclear weapon, China joined a U.N. Security Council resolution in favor of tough sanctions on North Korea. It has continued to oppose North Korea's nuclear ambitions, expressing "grave concern and opposition" and shifting from "diplomacy to punishment," the Council on Foreign Relations explained.

In 2017, for example, China temporarily cut off North Korea's access to coal imports and fuel. According to the Chinese General Administration of Customs, Chinese imports from North Korea dropped by a third in 2017. And, in the last several months, Chinese banks have begun to restrict the financial activities of North Koreans.

But China also scuttled U.N. efforts to impose more punitive sanctions on Pyongyang, signing on only after the international body scrapped its plans for an oil embargo and authorization to use force against ships that wouldn't comply with international inspections. Some critics also say China hasn't done enough to enforce the sanctions already in place, allowing businesses to operate across its border with relative impunity.

So whose side is China really on?

Ultimately, Xi is a pragmatist. His goals are to keep the peace between North Korea and the United States and to remain the major power player in the region. "As a next-door neighbor, China will not allow the US and North Korea to start shooting at each other with nuclear weapons in its own front yard," said Zhang Liangui, a professor for international strategic research at the Central Party School of the Communist Party of China, to Deutsche Welle. He'll throw his weight behind whomever will help him accomplish those aims.

If that means pressuring Kim to give up his nuclear weapons or allow more rigorous inspections, then that's what China will support. If it means nudging the United States to accept Kim's pledge to denuclearize on his own timetable, that's okay, too.

Read more: