The North said the test had been of a "newly developed nuclear warhead" and that it was now capable of mounting a nuclear device on ballistic rockets.
South Korean President Park Geun-hye called it an act of "self-destruction" showing the "maniacal recklessness" of leader Kim Jong-un. The US warned of "serious consequences".
China's foreign ministry said Beijing was resolutely opposed to the test and urged North Korea to avoid further action that would worsen the situation.