BEIJING — It was supposed to be Xi Jinping’s moment to bask in global prestige, as the Chinese president hosted the leaders of some of the world’s most dynamic economies at a summit meeting just weeks before a Communist Party leadership conference.

But just hours before Mr. Xi was set to address the carefully choreographed meeting on Sunday, North Korea’s leader, Kim Jong-un, detonated his sixth nuclear bomb.

Mr. Kim has timed his nuclear tests and missile launches with exquisite precision, apparently trying to create maximum embarrassment for China. And on Sunday, a gathering in southeast China of leaders from Russia, Brazil, India and South Africa, members of the so-called BRICS group, was immediately overshadowed by news of the test, which shook dwellings in China and revived fears of nuclear contamination in the country’s northeast region.

This is not the first time Mr. Kim has chosen a provocative moment to flaunt his country’s weapons. In May, he launched a ballistic missile hours before Mr. Xi spoke at a gathering of world leaders in Beijing assembled to discuss China’s signature trillion dollar One Belt, One Road project.