The country's official Korean Central News Agency said the test was performed underground and that there had been no radioactive leak from the site in the northeast of the country at Hwadaeri near Kilju at 10.36am (0136GMT) on Monday.
The agency said: "Our science research section has safely and successfully conducted an underground nuclear test.
"The nuclear test is a historic event that brought happiness to our military and people."
The South Korean intelligence officials detected a 3.58-magnitude seismic tremor.
The officials told South Korea's parliament that the test appeared to have been carried out in a 360-metre-high mountain northwest of the Musudan missile base in the Hwadaeri region.
Chung Hyong-Keun, a South Korean politician, quoted an intelligence official as saying: "In consideration of the height of the mountain, the test appeared to have been done in a horizontal tunnel."
The alleged test coincided with the ninth anniversary of the rise of Kim Jong-Il, North Korea's leader, to communist party chief.
The Japanese prime minister, Shinzo Abe, on a visit to South Korea, said information was still being gathered to confirm the test, estimated as being equivalent to 550 tons of TNT.
Roh Moo-hyun, the South Korean president, has convened a meeting of security advisers over the issue, and halted a shipment of aid to the North.
The government postponed the departure of a ship which was to leave for North Korea on Tuesday with 4,000 tons of cement on board.
North Korea said the test was
carried out near Kilju
A unification ministry official said: "The move, however, is temporary, and the government will decide later on whether to stop further aid shipments to North Korea."
South Korea suspended regular aid shipments to its impoverished neighbour after the North's missile tests in July.
But the following month it announced a one-off $230m emergency aid package after severe floods hit North Korea.
The UN Security Council is also expected to hold an emergency meeting on Monday to decide how to respond to the nuclear test.
The United States said that if confirmed, the nuclear test would be a "provocative act" and called for immediate action by the UN Security Council.
Tony Snow, White House spokesman, said: "We would expect the Security Council to meet Monday."
Last week, John Bolton, US ambassador to the UN, urged the council to respond to a test with punitive action going beyond the missile-related sanctions imposed on the North in a Security Council resolution passed in July.
Protesters with an effigy of the
North Korean leader
That resolution was passed after the North launched seven missiles, including a long-range Taepodong-2 believed to be capable of striking US soil.
The North said last week it would conduct a nuclear test as part of its deterrent against a possible US invasion.
The test caused alarm in the region, particularly in Japan. Shinzo Abe, the Japanese prime minister, had just arrived in South Korea for talks on North Korea's nuclear plans.
After discussions with Roh, Abe called for a "stern response" by the United Nations towards North Korea, saying its nuclear test was a threat to the entire world.
Abe said: "I have ordered the Japanese government to request the UN Security Council to start discussions on the North Korean nuclear issue promptly so that the world body could take undaunted action.
"North Korea's possible production and proliferation of nuclear arms would pose threats not only to Northeast Asia but also to the entire world."
Japan's PM said the test was a
threat 'to the entire world'
Roh, who said that the South may end its "sunshine" policy with the North, played down any differences in approach with Japan.
Roh said: "There were no differences between me and the Japanese prime minister on this issue.
"We agreed that we have to deal with this issue in a cool-headed manner. Coordinated responses within the UN and other countries are also required."
Tony Chang, Aljazeera's Beijing bureau chief, said the announcement of the test was a surprise despite earlier government announcements.
"Is it clearly aimed to coincide with the Japan prime minister, Shinzo Abe's trip to South Korea.
"It shows that China, who has been calling on North Korea to halt the test, doesn't necessarily have the power over the country that people think."
North Korea has long claimed to have nuclear weapons, but had never before performed a known test to prove its arsenal.