By Charles Scanlon
BBC News, Seoul
North Korea's claimed nuclear test is the culmination of nearly two decades of confrontation with the United States - a dangerous game of chicken in the heart of the world's most dynamic economic region.
North Korea's army is large but not advanced
Twelve years ago the United States mulled military strikes and the North threatened to turn Seoul into a "sea of fire" - all because North Korea threatened to reprocess plutonium from its small nuclear reactor at Yongbyon.
Now it has gone much further, claiming to have tested a bomb and amassed a nuclear arsenal.
And the reaction? A small and temporary blip on the South Korean stock market, a stiff talking to from China and a threat of "sanctions" from the United Nations.
Hardly the apocalypse that would once have been expected.
The reason is that over those 12 years, North Korea has used a barrage of threats and bluster to test the limits of Washington's tolerance - the famous "red line" that, once crossed, would provoke a military response.
The North gradually stepped up its nuclear activities. It fired up the moth-balled nuclear reactor at Yongbyon, reprocessed enough plutonium for about eight atomic bombs and has now claimed its first nuclear test.
A distracted US administration failed to come up with an effective or coherent response. It talked tough but failed to rally the rest of the region.
North Korea's leader Kim Jong-il and his generals appear to have drawn their own conclusions.
"They learned from Iraq that they need to be as nasty as they can be to avoid an invasion," says Peter Beck of the International Crisis Group in Seoul.
"And they learned from Pakistan that testing got US attention and respect. It moved from being a rogue to an ally."
Pyongyang has taken a gamble with its backers, China and S Korea
The North Korean economy is in ruins and the country relies on food handouts from friendly neighbours. But Kim Jong-il knows an admission of weakness would encourage his enemies.
Displays of military power have worked in the past to strengthen what appears at first sight to be a very weak hand.
The United States refused to reward "bad behaviour" or even negotiate when North Korea restarted its nuclear programme in 2003. Yet a year later it was offering a range of concessions, including security guarantees.
But North Korea continues to suspect American motives. It pulled out of six-nation nuclear talks when the United States targeted banks doing business with North Korea in what was called a crackdown on drug smuggling and money laundering.
Analysts say that decision helped trigger the nuclear test.
But there were probably other motives as well.
"North Korea's conventional army is very large but it's backward and it can't keep up with the new technology of South Korea and the United States," says Kim Tae-woo of the Korean Institute for Defence Analysis.
North Korea keeps a million-man army in the field and it claims the lion's share of the state's resources.
A credible nuclear deterrent could guarantee the security of the regime at much lower cost and free up resources for the beleaguered economy.
North Korea has clearly taken a gamble by defying its principal backers, China and South Korea.
Trade is booming with China, which also supplies aid in the form of oil and food. South Korea has stuck with its indulgent "sunshine" policy of engaging the North, despite its growing nuclear threat.
Both say North Korea must now pay a price. But they will work to dilute sanctions they consider too provocative. They fear sudden collapse and its resulting economic chaos even more than a nuclear-armed neighbour.
North Korea believes it can ride out another bout of international opprobrium and the limited sanctions that will ensue.
North Korea said it had no intention of exporting nuclear weapons when it threatened to test on October 3. That statement has since been picked up by senior US officials.
President George W Bush said any transfer of nuclear weapons or material by North Korea to others would be "a grave threat" to the US.
The North believes it has found Washington's new "red line", and that the US will learn to live with a new nuclear state in north-east Asia.