It appears to have been a much more powerful blast than North Korea's first nuclear test, in October 2006.
BBC world affairs correspondent David Loyn says North Korea appears to have moved from a posture of negotiation to confrontation over the nuclear issue.
'Stronger than 2006'
Obama rebukes 'reckless' N Korea
An official communique read out on North Korean state radio said another round of underground nuclear testing had been "successfully conducted... as part of measures to enhance the Republic's self-defensive nuclear deterrent in all directions".
The North did not report the test site but South Korean officials placed it in the north-eastern region around the town of Kilju, the site of North Korea's first nuclear test.
Quentin Sommerville, BBC News, Beijing
Even North Korea's closest ally is losing patience with Pyongyang. China's foreign ministry says that North Korea has ignored international opposition and that the Chinese government resolutely opposes today's nuclear tests.
Those are strong words but they're also very familiar. Back in 2006, China condemned an earlier nuclear detonation as a brazen act. Then, as now, it urged North Korea back to the negotiating table.
But Pyongyang doesn't appear to be listening. Even though it depends on China's protection and support, North Korea is nobody's puppet.
Even with this latest nuclear test, another snub to China's leadership, there's little appetite in Beijing for tightening the screws on its neighbour. Doing so might spark a humanitarian or political crisis which could send hundreds of thousands or millions of refugees pouring over China's 800-mile long shared border. As powerful as China is, even it can't risk forcing Pyongyang's hand.
Monitors from the Comprehensive Nuclear Test Ban Treaty Organisation had been unable to determine if the event had a "nuclear background", its executive secretary, Tibor Toth, told reporters.
However, they did detect a "very close-to-surface type of event" measuring 4.5 on the Richter scale, Mr Toth said. That would make it stronger than the October 2006 test, which had a magnitude of around 4.1.
Russia's defence ministry estimated a blast of up to 20 kilotons - comparable to the American bombs that flattened Hiroshima and Nagasaki in 1945.
A US official in Washington, who spoke to Reuters news agency on condition of anonymity, said Pyongyang had given less than an hour's notice of the test, and had made no demands.
The message was conveyed through the "New York channel", the official added, referring to contacts between North Korean diplomats and US officials at the UN.
There are unconfirmed reports that North Korea also test-fired two short-range missiles.
Speaking outside the White House, US President Barack Obama said the US would work with its allies around the world to "stand up to" North Korea.
The time to be worried has long passed
Michael, Israel (currently in the US), BBC News website reader
"North Korea has previously committed to abandoning its nuclear programme," he said.
"Instead of following through on that commitment, it has chosen to ignore that commitment. Its actions have also flown in the face of United Nations resolutions. As a result North Korea is not only deepening its own isolation it's also inviting stronger international pressure."
South Korea said the test was an intolerable "provocation" while Japan said any nuclear test by the North was "unacceptable", and both said they would ask for action from the Security Council.
UN Secretary General Ban Ki-moon said he was "deeply disturbed". UN Security Council Resolution 1718 demands that North Korea refrain from nuclear testing.
UK Prime Minister Gordon Brown said the test would "undermine prospects for peace on the Korean peninsula".
Russia and China echoed the words of condemnation with Beijing saying it was "resolutely opposed" to the test and Moscow describing it as a "blow to non-proliferation efforts".
Both urged North Korea back to the negotiating table.
The six-party disarmament talks - involving the US, China, Japan, Russia and the two Koreas - stalled last year over Pyongyang's failure to agree how information it has handed over on its nuclear activities and facilities should be verified.
NORTH KOREA'S SUSPECTED NUCLEAR TEST SITE
Nuclear test on 25 May 2009 is thought to have been carried out at same site as October 2006 test
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.