North Korea is to conduct a nuclear test to "bolster" its self-defence in the face of US military hostility, the foreign ministry has said.
In a statement, it said North Korea would carry out the test "in the future... where safety is firmly guaranteed" - but did not say when.
North Korea has come under mounting pressure over its nuclear programme.
Six-nation talks have stalled and the UN has condemned North Korea for missile tests launched in July.
North Korea is believed to have a handful of nuclear warheads but is not known to have tested one.
The statement from Pyongyang said North Korea would "in future conduct a nuclear test under the condition where safety is firmly guaranteed".
It accused the US of causing a "grave situation ... in which the supreme interests and security of our State are seriously infringed upon and the Korean nation stands at the crossroads of life and death".
It went on to say "the US extreme threat of a nuclear war and sanctions and pressure compel [North Korea] to conduct a nuclear test, an essential process for bolstering nuclear deterrent".
It added that the country would "never use nuclear weapons first but strictly prohibit any threat of nuclear weapons and transfer".
And it said that North Korea "will always sincerely implement its international commitment in the field of nuclear non-proliferation as a responsible nuclear weapons state".