The nuclear test quickly increased tensions between the United States and China. In a strong rebuke on Thursday, Secretary of State John Kerry called China's approach to North Korea a failure, saying that something had to change in its handling of the isolated country it has supported for six decades. On Friday, China suggested that it was the Americans, not the Chinese, who were largely to blame for the North's nuclear program.
The United States also used the North's test to tighten a trilateral alliance with Japan and South Korea, a relationship that China has long viewed as a check on its power.
"This is exactly what North Korea wanted," said Go Myong-hyun, a research fellow at the Asian Institute for Policy Studies in Seoul. "If its erratic behavior drives South Korea closer to the United States, China will feel more surrounded, and that will give North Korea room for maneuver."
Pyongyang has often lashed out when it felt ignored, especially by the United States, using threats and provocations to force its opponents to engage in dialogue or offer inducements, like badly needed aid or a peace treaty to formally replace the Korean War armistice.
But for Kim to thumb his nose at China, he is gambling that Beijing will continue to believe that keeping a nuclear-armed North Korea on its border as a buffer against the Americans and South Koreans is more important than forcing it to denuclearize at the risk of its collapse.
That is a big wager. President Xi Jinping of China is deeply distrustful of his counterpart, according to several Chinese diplomats and scholars, though he has sought a warmer relationship with the North in recent months. He sees Kim as naive and impetuous, analysts said, and he is concerned about the country's growing nuclear arsenal.
But Xi, who has adopted an assertive approach to foreign policy, is hampered by political and military realities, including a worry that destabilizing the North could result in a chaotic influx of millions of refugees and cede territory to South Korea, a close U.S. ally.
As pressure grows on China to take a leading role in restraining North Korea, by cutting oil shipments and disrupting financial transactions, Xi faces a critical test of his presidency: whether he can subdue a young, volcanic leader without undermining China's own interests.
"The stars are probably as aligned as you could make them for Xi Jinping to do something unconventional and unprecedented," said Evans J.R. Revere, a former senior State Department specialist on North Korea. "It's really an open question as to whether he's prepared to do that."
The North Korean test has also increased pressure on President Park Geun-hye of South Korea. Despite criticism from Tokyo and some misgivings in Washington, Park has doggedly cultivated closer ties with China, hoping that approach would help tame North Korea.
At the same time, she shared Washington's "strategic patience," a policy of squeezing North Korea with sanctions and offering serious deals only if it agreed to give up his nuclear weapons, even when the North was known to be stocking fuel for more nuclear bombs.
In the wake of the North Korean test, her domestic critics said none of her approaches had worked.
Since he came to power four years ago, Kim has begun a series of what outside analysts call window-dressing projects: amusement parks, ski resorts, high-rise apartment buildings in Pyongyang - still suffering from electricity shortages despite being the capital.
Most of the country, especially outside the capital, remains in dire poverty, a fact that analysts say has spurred Kim to focus attention on his nuclear program.
"Tensions with the external world is probably what he wanted, a good excuse for him to shift the blame for his failure to improve his people's living standards," said Koh Yu-hwan, a professor of North Korean studies at Dongguk University in Seoul.
"I see a desperate young leader struggling to establish himself among his people who are still unsure of his economic credentials and in a region that has become increasingly unfriendly to his country," he said.
Yet despite the scrutiny he draws, Kim has always been a puzzle to outside analysts.
The world had never seen Kim until the North's state-run media carried photos of him, then in his late 20s, attending a party meeting in 2010, where he debuted as heir to his father, Kim Jong Il.
Since inheriting power after his father's death the next year, he has proved as Machiavellian as his forebears of the totalitarian dynasty.
He replaced or shuffled crucial posts of power in the party and military and executed potential threats, including his uncle, Jang Song Thaek.
Last month Moranbong, a female pop group whose members were said to be handpicked by Kim, canceled a concert in Beijing and returned home in a huff. No explanation was given. But subsequent media reports from Beijing suggested that the group and its Chinese host argued over the list of songs, some of which glorified Kim and his nuclear weapons. Two days after the group returned home, Kim signed an order to send the "thunderclap of an H-bomb."
Kim - who apparently celebrated his 33rd birthday on Friday - cultivates his cult of personality carefully.
Over the years, he has gained weight and cut his hair to look like his grandfather, the North's founding president, Kim Il Sung, still a godlike figure there. He likes to sit and smoke while party secretaries and generals older than his father stand around him.
He also appears to enjoy being hugged by soldiers. When he visits front-line islands, the entire village turns out, all frantically waving, many even wading into the water to send him off.
A crucial prop of Kim's rule is the nuclear arsenal. North Korea calls it the "treasured sword" of self-defense that he has secured for his people, who are seen as being forced to live fear of U.S. invasion.
He has been a master of perpetuating that view of the world to North Koreans. On Friday, North Korea released television footage, part of a documentary glorifying Kim's leadership, indicating that its development of a submarine-launched ballistic missile was more advanced than previously thought.
In the footage, reported by the South Korean news agency Yonhap, Kim is seen standing on the deck of a ship, watching a missile rise from the water into the clouds. The authenticity of the images could not be independently confirmed.