Nuclear devices are often tested underground to prevent radioactive material released in the explosion reaching the surface and contaminating the environment.
This method also ensures a degree of secrecy.
The release of radiation from an underground nuclear explosion - an effect known as "venting" - would give away clues to the technical composition and size of a country's device, and therefore its nuclear capability.
The test site is carefully geologically surveyed to ensure suitability. Such tests usually take place well away from population centres.
The nuclear device is placed into a drilled hole or tunnel usually between 200-800m (650-2,600ft) below the surface, and several metres wide.
A lead-lined canister containing monitoring equipment is lowered into the shaft above the chamber. The hole is then plugged with gravel, sand, gypsum and other fine materials to contain the explosion and fallout underground.
The device is remotely detonated from a surface control bunker. The nuclear explosion vaporises subterranean rock, creating an underground chamber filled with superheated radioactive gas.
As this cools, a pool of molten rock collects at the bottom of the chamber.
Minutes or hours after the blast, as the pressure falls, the chamber collapses in on itself causing subsidence and a crater to appear on the surface.
North Korea's test
Seismic waves equivalent to a 5.1-magnitude earthquake were registered near the Punggye-ri nuclear site in a remote area in the east of the country, rattling Chinese border cities.
Hours later, state media announced the first "successfully performed" underground test on a hydrogen bomb.
Nuclear experts have expressed some scepticism, saying they would have expected a larger blast from an H-bomb, but it could be weeks before independent tests can verify or dismiss the claim.
This is the fourth nuclear test carried out at Punggye-ri - the previous ones were carried out in 2006, 2009 and 2013.