North Korea "has ignored the international community's widespread opposition, again carrying out a nuclear test. China's government expresses resolute opposition and strong condemnation toward this," the foreign ministry said in a statement on its website.
"We strongly urge the DPRK (North Korea) to face the strong will of denuclearisation from the international community, earnestly abide by the relevant resolutions of the UN Security Council, stop taking mistaken actions which worsen the situation and are also not in line with its own interests, and effectively return to the track of solving the problem through dialogue," it added.
Pyongyang declared the test of what it called a hydrogen bomb to be a "perfect success."
Beijing is North Korea's main diplomatic ally and economic supporter and is seen as playing a crucial role in efforts to get Pyongyang to curb its weapons programme.
More From This Section
The test came just hours before Chinese President Xi Jinping was scheduled to open a summit of BRICs nations in southern China.
North Korea's actions create a potentially embarrassing situation for Xi, who is preparing for a politically sensitive gathering of the ruling Communist Party in October, at which he aims to further consolidate his power.
It was the second time this year that North Korea has timed a weapons test to coincide with a major international political gathering in China.
In May Pyongyang fired a ballistic missile as leaders from 29 nations gathered in Beijing for a summit touting China's new Silk Road project.