by Blaine Harden

To the frustration of President Trump, China seems to be losing leverage over the young dictator next door. North Korean leader Kim Jong-un keeps biting the hands of Beijing elders who provide his otherwise friendless state with fuel, food and diplomatic cover.

Those bites have challenged China’s authority, embarrassed its leaders and stymied U.S.-backed efforts by Beijing to restrain Kim’s flirtation with global nuclear war. Several recent incidents suggest a growing trend:

• North Korean spies are prime suspects in the sensational nerve-gas killing early this year in Malaysia of Kim’s half brother, Kim Jong-nam, a resident of the Chinese territory of Macau, where he was under the unofficial protection of China. As FRONTLINE reports this week, Kim Jong-nam had supported Chinese-style economic reforms in the North and was seen by some as a possible replacement for Kim Jong-un.

• The detonation in September of North Korea’s largest nuclear device, which it called a hydrogen bomb, disrupted a summit meeting of world leaders in Beijing, embarrassing Chinese President Xi Jinping. It wasn’t the first time. North Korea launched a missile in May just before Xi was to speak to dignitaries. Xi’s new envoy to North Korea has not even been allowed into the country.

• Ignoring repeated warnings from China, Kim Jong-un has accelerated the frequency and increased the range of long-range ballistic missile tests. At the same time, his regime has blamed Beijing for a “reckless act of chopping down” trust between the countries.

What motivates Kim Jong-un to alienate the affections of an ally that accounts for 90 percent of the North’s trade? What does he have against China?

Totalitarian leaders usually don’t explain themselves and Kim Jong-un — six years in power and still only 33 — is no exception. But insights into his Sino-belligerence can be gleaned from the backstory of his family. In nearly 70 years of dealing with their powerful patrons in Communist China, three generations of dictators named Kim have lurched between dependence and distrust, cooperation and contempt. The family’s unruly behavior suggests there is little reason to assume — as Trump and other American presidents sometimes have — that China can impose its will on North Korea.

The edgy attitude of the Kim family is likely rooted in the arrest and humiliation at Chinese hands of Great Leader Kim Il-sung, North Korea’s founding despot and the late grandfather of Kim Jong-un.

Kim Il-sung grew up in northeast China, where in the 1930s he became a guerrilla leader and fought alongside Chinese Communist partisans against Japanese occupiers. Without warning, local Communists turned on Kim and his men. Several hundred ethnic Koreans were tortured and murdered in a racist purge based on the party’s paranoid, and false, belief that they were secretly working with the Japanese.

Kim was arrested in China in 1934 and was lucky to survive. He later called the purge “a mad wind … [Koreans] were being slaughtered indiscriminately by [Chinese] with whom they had shared bread and board only yesterday.”

During the Korean War, his bitter memories were compounded by a painfully public loss of face. Kim Il-sung started the war in 1950 by invading South Korea with the backing of Stalin’s Soviet Union. But his army was soon obliterated by an American-led coalition and North Korea all but disappeared — until Chinese forces entered the fight and forced Kim to the sidelines of his own war. China’s top general, Peng Dehuai, chided Kim for his “extremely childish” leadership, telling him, “You are hoping to end this war based on luck.”

Kim Il-sung would never forget how he was treated. After the war, he made sure that China’s role in saving and rebuilding his state was largely erased from official histories. His resentment was compounded in 1980, when China publicly denounced as feudalism his decision to transfer absolute power to his son, Kim Jong Il, a succession that made North Korea the world’s only hereditary Communist kingdom.

Kim Il-Sung waves during a celebration marking his 80th birthday in April 1992. Kim was arrested in China in 1934 and later called the purge that ensnared him “a mad wind.” (JIJI PRESS/AFP/Getty Images)

Ill feelings between North Korea and China have often been mutual. Mao Zedong regarded Kim Il-sung as rash and doctrinaire — once describing him as “a number-one pain in the butt.” In 1992, China infuriated the Kim family by establishing diplomatic relations with South Korea, the archenemy of the North.

Still, Chinese leaders from Mao to Xi have chosen to protect and prop up the troublesome Kim regime, fearing that its collapse would trigger a flood of refugees and lead to a U.S.-allied, united Korea on its border. As North Korea’s international isolation has increased along with its nuclear prowess, the Kim regime has become more dependent than ever on Chinese trade.

That dependence, however, is clearly not swaying the behavior of Kim Jong-un, who imitates the sartorial style and ruling substance of his grandfather. He cuts his hair like Kim the First and has a similar pear-like physique. In his interactions with North Koreans young Kim affects the smiling, man-of-the-people mien of his grandfather, who was that rarest of rulers, a tyrant who oppressed his people for nearly half a century yet died in 1984 with a genuine hold on their affections.

By routinely flouting the instructions of leaders in Beijing, Kim Jong-un also seems to have internalized his grandfather’s grudges. In late September, when Kim Jong-un was insulting President Trump for being a “mentally deranged U.S. dotard,” a commentary in the Korean Central News Agency attacked the media in Beijing for being “rude” and “shameless.” It also said that North Korea owed little to China.

The commentary was signed by “Jong Phil,” which means “righteous pen,” and was the third such anti-China article written by him this year. A China scholar, Adam Cathcart at the University of Leeds, told The Washington Post that he believes Jong Phil is a pen name for Kim Jong-un.

Blaine Harden, a former reporter for The Washington Post, is the author of King of Spies: The Dark Reign of America’s Spymaster in Korea and a consultant to the FRONTLINE documentary “North Korea’s Deadly Dictator” airing on PBS on Oct. 4. A version of this essay appeared in The Washington Post.