Little more than four years ago, the North Korean nuclear weapons program was largely under lock and key, the threat seen as a fleeting crisis of a previous decade.
North Korea's main nuclear center at Yongbyon, 60 miles north of Pyongyang, was monitored 24 hours a day by U.N. surveillance cameras. International inspectors lived near the site. Seals were in place over key nuclear installations and a nuclear reactor at Yongbyon was gathering dust.
So what went wrong?
The story of Monday's announcement of a nuclear test is one of failed policies, neglect and missed opportunities by the Bush administration and its predecessors.
It is also the story of how a cagey dictator, Kim Jong Il, took advantage of the United States' entanglement in Iraq to advance his nuclear agenda.
"When you start the debate about 'Who lost North Korea?' " said Scott Snyder, a North Korea expert with the Washington-based Asia Foundation, "there will be many places to lay" the blame.
North Korea's founder, Kim Il Sung, well aware that the United States had considered using nuclear weapons in the 1950-53 Korean War, first began a nuclear energy program in the 1960s with help from his patrons in the Soviet Union. His son, the present leader, accelerated the program in the early 1990s, and the Clinton administration grew concerned.
In 1994, the United States struck a deal known as the Agreed Framework, under which North Korea agreed to place its nuclear facilities at Yongbyon under a U.N.-monitored freeze in return for energy assistance and help building light-water nuclear reactors, which are harder to use for military purposes.
Relations warmed somewhat, and in 2000 then-Secretary of State Madeleine Albright traveled to Pyongyang to meet Kim Jong Il. Normalization of relations appeared imminent.
All that changed when George W. Bush became president. Bush quickly made public his loathing for Kim and the regime. Republicans were particularly scornful of the agreement to give energy assistance to North Korea and looked for ways to void the pact.
The opportunity presented itself during the first visit by a Bush administration envoy to Pyongyang in October 2002. Assistant Secretary of State James A. Kelly was told by a North Korean official that the North was cheating on its nuclear freeze obligations by conducting secretive research into highly enriched uranium. As fuel for a nuclear weapon, highly enriched uranium is an alternative technology easier to keep hidden than a plutonium-based program, which requires a reactor such as the one at Yongbyon.
The Bush administration moved hastily to punish North Korea by cutting off shipments of fuel oil that had been pledged under the Agreed Framework.
Within weeks, the North Koreans put tape over the surveillance cameras at Yongbyon and broke the seals on their nuclear installations. By New Year's Eve, the U.N. inspectors were escorted out of North Korea.
The Asia Foundation's Snyder said the Bush administration was justified in its actions. It was also evident that Pakistani nuclear scientist Abdul Qadeer Khan had been helping North Korea undertake a highly enriched uranium program on the sly. The Clinton administration, Snyder said, was sloppy in not following up on tips as far back as 1998 of North Korean efforts to procure uranium technology.
At the same time, the United States ended up in effect throwing away a deal that had kept the more immediately threatening plutonium production facility at Yongbyon in check.
"We wanted to catch them cheating. We focused on moral indignation at the expense of our national interests," Snyder said.
Once the U.N. inspectors were gone, North Korea wasted no time. By mid-2003, it had repaired its mothballed nuclear reactor and cranked up the reprocessing plant where weapons-grade plutonium was extracted from spent fuel rods.
The United States issued shrill warnings to the North Koreans, but they sounded increasingly hollow given the entanglement in Iraq. The North Koreans continually appeared to be calling the United States' bluff.
And if the Bush administration expected the removal of Saddam Hussein to deter Kim Jong Il from forging ahead, it was in for a disappointment. The North Koreans said they needed nuclear weapons to prevent the United States from exercising the doctrine of preemption on their territory.
"We're not like Iraq or Yugoslavia or Afghanistan. We can defend ourselves," Kim Myong Song, a North Korean guard at Mt. Kumgang, boasted to The Times last year.
North Korea trumpeted each and every step toward completing its nuclear weapon. Its news service declared it had reprocessed fuel rods into plutonium. The regime said it had a "nuclear deterrent" and warned repeatedly they it would conduct a nuclear test.
Usually regimes develop weapons of mass destruction in secret. North Korea's boastfulness led analysts to speculate that perhaps this was Pyongyang's cry for attention from Washington.