A cheap switch was all that prevented a nuclear bomb exploding over North Carolina in 1961, newly declassified documents reveal.

The 4 megaton device was 240 times more powerful than the bomb dropped on Hiroshima, and would have devastated swathes of North America.

The report, obtained by the Guardian, describes how only days after the inauguration of President John F Kennedy, on January 23 1961, a B52 bomber loaded with hydrogen bombs set off from Seymour Johnson Air Base in North Carolina for a routine flight to the east coast when it got in to trouble and went into a tailspin.

A device in the cockpit released two Mark 39 hydrogen bombs over the town of Goldboro. One did not activate and fell to the ground. The other "assumed it was being deliberately released over an enemy target - and went through all its arming mechanisms save one, and very nearly detonated over North Carolina," journalist Mark Schlosser, who acquired the documents through the Freedom of Information Act request, told the BBC.

In the report, written eight years after the incident, US government scientist Parker Jones, who was responsible for the safety of nuclear devices, concludes that three of the four safety devices designed to prevent the bomb detonating accidentally had not worked, and that the final switch that prevented catastrophe could have easily been knocked out by an electrical surge.

"It would have been bad news - in spades," said Jones, who drily entitled his report Goldsboro Revisited or: How I learned to Mistrust the H-Bomb - a quip on Stanley Kubrick's 1964 satirical film about nuclear holocaust, Dr Strangelove or How I Learned to Stop Worrying and Love the Bomb.

"The MK 39 Mod 2 bomb did not possess adequate safety for the airborne alert role in the B-52," Jones concludes.

The activated device landed in a field near Big Daddy's Road, the report states. The other bomb was found hanging in a tree from its parachute.

Schlosser told the BBC that if the device had exploded it would have "changed, literally, the course of history".

"The US government has consistently tried to withhold information from the American people in order to prevent questions being asked about our nuclear weapons policy," he said. "We were told there was no possibility of these weapons accidentally detonating, yet here's one that very nearly did."