President Donald Trump’s bromance with Chinese president Xi Jinping has yielded few practical results. To the contrary, U.S.-Chinese relations increasingly seem headed for rough waters.

Nothing has been resolved on economic issues, so Washington is rolling out another set of trade penalties. Beijing appears to be abandoning Deng Xiaoping’s old policy of patience and is moving ever closer to political and military confrontation with Taiwan. The People’s Republic of China (PRC) also continues to aggressively press its expansive territorial claims in the Asia-Pacific; in response, the U.S. Navy ran another Freedom of Navigation Operation a few days ago.

Then there is North Korea. Last year the president blamed the PRC for not doing enough to pressure the North, before thanking President Xi for his efforts. But after the North’s recent angry eruption, or “different attitude,” as President Trump put it, he appeared to again blame China: “I think I understand why that happened,” said President Trump, but “I can’t say that I’m happy about it.” He went on to cancel, perhaps only temporarily, the planned summit with Supreme Leader Kim Jong-un.

Apparently the president believed that Kim was ready to toss away his nuclear weapons, and who knows what else, until President Xi summoned Kim to Beijing and issued contrary instructions. (John Bolton highlighting the “Libya model,” which made possible that government’s overthrow, twinned with the president’s and vice president’s threats of military action, are far more likely culprits for Pyongyang’s shift.)

President Trump is not the only one to assume that the Democratic People’s Republic of Korea was China’s puppet. Sen. John McCain once urged threatening the entire U.S.-PRC relationship if Beijing did not rein in the North. More recently Joseph Bosco, who served in the Bush Defense Department, charged China with “blatant sabotaging of the promising dialogue” between the United States and North Korea (DPRK).

Matthew Continetti of the Free Beacon argued that “the two governments function in a close alliance. North Korea would not exist without Beijing’s support.” Indeed, he added, “We don’t have a North Korea problem. We have a China problem. North Korea is a wild dog—China holds the leash. To change North Korea’s behavior, change Chinese behavior first.”

In fact, Pyongyang is resisting administration demands because Kim believes they are not his nation’s, or at least his regime’s, interest. From the beginning the DPRK has resolutely resisted foreign pressure. Long ago even the PRC discovered the limits of its influence in the North.

Beijing wants a stable, docile, non-nuclear Korean buffer state. That would enhance China’s regional influence, prevent the peninsula from being used as a tool of containment, spark allied requests for Chinese help to “manage” the North, and preserve a relationship with both historical and ideological significance. In contrast, a nuclear DPRK ensures Pyongyang’s independence, including from the PRC, and generates American complications.

Unfortunately for Beijing, its buffer state was always unruly and recently went nuclear. Until recently, at least, the Chinese leadership decided that buffer took precedence over nuclear. Especially since the PRC’s influence in the North was substantially more limited some observers assumed. The Beijing-Pyongyang relationship was not unlike America’s support for brutally repressive regimes—think Egypt or Saudi Arabia today—which nevertheless were believed to advance other U.S. interests.

North Korea was birthed by the intersection of World War II and the Cold War. The Soviets occupied the northern half of the Korean Peninsula, chose Kim Il-sung as leader of what became the new state and okayed his plans for war. America intervened in the ensuing conflict and its forces soon threatened to overrun the DPRK. Only Mao Zedong’s decision to confront the United States—to protect the PRC, not North Korea—preserved Kim’s rule.

The cost was high: among the hundreds of thousands of Chinese casualties was Mao’s son. But Kim offered few thanks to China. Even today the Victorious Fatherland War Museum suggests that it was Kim, plus a few courageous North Korean soldiers, who almost defeated the American imperialists, South Korean puppets and allied satellites. When visiting last year I saw no monuments to Chinese soldiers.

Along the way to absolute power Kim crushed the pro-China faction, over the PRC’s protests. He played Moscow against Beijing, criticizing both Khrushchev, who had denounced Stalinism, and Mao, who had opposed Kim turning a nominally Communist state into a de facto monarchy. Only out of necessity did Pyongyang maintain a civil relationship with the PRC after the latter established diplomatic relations with Seoul.

Since then the relationship between the two supposed allies has oscillated, but generally grown increasingly strained. For years the PRC pressed its small neighbor to follow China in adopting economic reforms, while eschewing production of nuclear weapons. Kim Jong-il, who took over from Kim Il-sung in 1994, did the opposite. Kim Jong-un succeeded his father in December 2011 and seemed more interested in economic development, but accelerated nuclear and missile testing. Moreover, five years ago he executed his uncle, Jang Song-thaek, who was his nation’s principle interlocutor with Beijing. Jang was accused of making improper deals with an unnamed country—but whose identity was not difficult to guess.

Nevertheless, complained Bosco, the PRC enabled the North’s ambitions “by protecting successive Kim regimes from United Nations-imposed and other economic sanctions.” Indeed, despite China’s evident irritation with Pyongyang the former moderated Washington’s demands on Pyongyang.

Why? Continetti claimed: “Beijing protects North Korea precisely because it fears nothing more than another democracy on its borders.” Actually, China feared instability and collapse more than democracy, rather like Washington would view a possible Mexican implosion.

The PRC also worried about a unified Korean state which might create a magnetic attraction to ethnic Koreans who populate China’s border provinces. In control of the entire peninsula, South Korea could ultimately become a more significant international actor, potentially part of a U.S-orchestrated containment system. In fact, in 1950 Beijing want to war to prevent a united Korea allied with America and hosting U.S. troops on its border. China might not go to war with Washington today to stop such a contingency, but the Chinese government certainly wouldn’t want to encourage such an event. One could have only imagined America’s reaction to Canada joining the Warsaw Pact.

Thus, preserving the often insufferable Kim dynasty made sense for the PRC. However, in recent years Chinese attitudes have hardened. Academic and popular sentiments long ago turned against the North. Kim earned such sobriquets as ‘Fatty Kim’ and ‘Kim the Fat’ on Chinese social media. Government policy, too, shifted, though more slowly. After every North Korean test Beijing agreed to tighter restrictions and increasingly enforced them. The Xi government not only objected to the North’s missile and nuclear developments but sought to preclude U.S. action, most notably secondary economic sanctions and military action. The PRC once accounted for 90 percent of the DPRK’s trade but Chinese economic ties in the North fell sharply last year.

At this point China and North Korea barely qualified as frenemies. President Xi had steadily tightened sanctions and enforcement. Six years after Kim ascended to the North Korean throne he had yet to receive an invitation to the PRC, yet South Korea’s president met with Xi a half dozen times and even enjoyed a place of honor during the 2015 parade celebrating the seventieth anniversary of the end of World War II. The DPRK was in the equivalent of Xi’s doghouse.

Could the alleged strain between Pyongyang and Beijing have been an elaborate ruse, as some originally suspected the break between Moscow and Beijing to be? If so, it was very well-disguised.

Indeed, the Chinese deep freeze probably encouraged Pyongyang to play the America card. Events earlier this year created a fearsome prospect for Beijing: an autonomous DPRK friendly to America. That fear likely motivated the two Xi-Kim summits between March and May.

Xi watched as Kim met with South Korea’s president Moon Jae-in and planned a summit with President Trump. There even were rumors of a possible tete-a-tete with Russian president Vladimir Putin. Moreover, Moon said that the North made no demands regarding the presence of U.S. troops in the South, a traditional concern of China. Kim appeared to be negotiating with everyone else about the future of Northeast Asia, while signaling Beijing that he did not intend to represent the PRC’s interests while talking to America.

Indeed, analysts long suspected that Pyongyang might not object to a U.S. role in Northeast Asia so long as Washington’s intentions toward the North were no longer ill. Just as South Korea, playing the traditional “shrimp among whales” role, looked to distant America for support, so might the DPRK. Which would leave China essentially friendless and even more vulnerable to U.S. containment efforts.

Which made it imperative for Beijing to cater to Kim. China almost certainly was the supplicant, offering the DPRK what the latter long desired. Promises of support rather than orders for obstruction likely came out of the two Xi-Kim meetings. Beijing still wanted North Korea to negotiate, but not from a position of weakness ready to toss the PRC under the proverbial bus.