The North's threat coincided with a visit to Seoul by the U.S. special envoy on North Korea, Glyn Davies, who urged Pyongyang not to go ahead with a third test.
"Whether North Korea tests or not, it's up to North Korea," Davies told reporters after a meeting with his South Korean counterpart, speaking shortly before the North's statement.
"We hope they don't do it, we call on them not to do it. It would be a mistake and a missed opportunity if they were to do it," he said.
South Korea's foreign ministry spokesman voiced deep regret over the test threat and urged Pyongyang to heed the "constant warnings" against further provocative acts.
Much of the North's statement was devoted to condemning Tuesday's announcement by the UN Security Council of expanded sanctions against Pyongyang in response to its long-range rocket launch last month.
"We absolutely refute all the illegal and outlawed resolutions adopted by the Security Council," the commission said.
Tuesday's resolution, proposed by the United States, was adopted unanimously by the 15-nation council, including the North's sole major ally China.
As well as adding a number of North Korea entities and individuals to an existing UN sanctions list, the resolution threatened "significant action" if the North stages a nuclear test.
North Korea's foreign ministry reacted defiantly on Wednesday, when it also gave the first hint that Pyongyang would react with a nuclear test by vowing "physical actions" to boost its nuclear deterrent.
South Korean defence ministry spokesman Wi Yong-Seop told reporters that Seoul believed the North was capable of conducting a test "any time its leadership decides to do so".
Last month a U.S. think-tank reached a similar conclusion based on satellite photos, suggesting the North had repaired rain damage at its nuclear test site and could conduct a detonation at two weeks' notice.