Barack Obama has vowed to take "swift and credible action" over North Korea's "highly provocative" nuclear test which appeared to bring Pyongyang closer to producing a viable weapon.

The United Nations security council held an emergency meeting in New York on Tuesday morning to "strongly condemn" Pyongyang's most powerful underground blast to date as a "clear threat to international peace and security".

The council called the test a "grave violation" of earlier resolutions and warned that it will strengthen sanctions just three weeks after the latest wave took effect.

But North Korea remained defiant, describing the test as a "preliminary measure" and threatening "stronger" actions unless the US ends its "hostility".

Experts said the explosion appeared to be an important step toward developing a nuclear bomb capable of fitting to a long range missile.

South Korea raised the level of its military alert.

Pyongyang's defiance was expected to force its way in to Obama's state of the union speech on Tuesday because the president was planning to make a call for a cut to nuclear weapons stockpiles worldwide. But while Obama's frustration was evident from the strength of his denunciation, it is less clear what the US can do about North Korea's actions.

"This is a highly provocative act that, following its December 12 ballistic missile launch, undermines regional stability," said Obama. "North Korea's nuclear weapons and ballistic missile programs constitute a threat to US national security and to international peace."

North Korea described the latest nuclear test as a "first response" aimed at defending itself from the "US threats".

"This nuclear test was our preliminary measure, for which we exercised our most restraint," an unidentified North Korean spokesman told the state news agency. "If the United States continues to come out with hostility and complicates the situation, we will be forced to take stronger, second and third responses in consecutive steps."

The ministry did not say what those steps might be.

Obama said the nuclear test offered only an illusion of greater security.

"These provocations do not make North Korea more secure. Far from achieving its stated goal of becoming a strong and prosperous nation, North Korea has instead increasingly isolated and impoverished its people through its ill-advised pursuit of weapons of mass destruction and their means of delivery," he said.

"The danger posed by North Korea's threatening activities warrants further swift and credible action by the international community. The United States will also continue to take steps necessary to defend ourselves and our allies."

The test was condemned by other countries including China, which is best placed to pressure the North Korean government with measures such as cutting oil supplies but has so far backed only limited sanctions.

The UN secretary general, Ban Ki-moon, called Pyongyang's actions "deplorable" in ignoring international opinion. The British foreign secretary, William Hague, described the nuclear test as a "clear and grave violation of the relevant UN security council resolutions" and said that North Korea faced further isolation.

The North Korean test may have been timed to coincide with Obama's state of the union speech in which he planned to call for a sharp drawdown in the number of nuclear warheads, proposing to drop the US arsenal from about 1,700 to 1,000.

It was to be one element in a speech expected to define Obama's second term agenda and announce a number of initiatives, including plans to more than halve the 66,000 troops the US has in Afghanistan by this time next year as the Pentagon prepares for the final pullout of combat forces by the end of 2014.

The president is expected to strongly press comprehensive immigration reform and to renew his call for an assault weapons ban in the wake of the school shooting in Newtown, Connecticut.

The White House, along with congressional Democrats, has invited dozens of victims of gun crime or their relatives to attend the speech. Among Michelle Obama's guests will be the parents of Hadiya Pendleton, 15, who participated in the president's inaugural parade last month and was then killed in a shooting in Chicago.

Among others attending the speech will be former Arizona congresswoman Gabrielle Giffords, who was badly wounded in a shooting in Tucson two years ago.

To counter the move by supporters of more gun control, a Texas congressman, Steve Stockman, has invited rock star Ted Nugent to attend. Nugent is an ardent supporter of the National Rifle Association, and last year said he would either be "dead or in jail" if Obama were re-elected.

Obama is also expected to tick boxes on the need to combat climate change and in favour of clean energy, although there appears little chance of the president getting major environmental legislation through the Republican-controlled House of Representatives.

But the White House has indicated that the core of the president's speech will focus on strategies to strengthen the American middle class as a means of bolstering a slowly improving economy. Obama told Democratic party members of the House on Thursday that job creation remains at the heart of that.