New video footage has been released for the first time of the moment Guardian editors destroyed computers used to store top-secret documents leaked by the NSA whistleblower Edward Snowden.

Under the watchful gaze of two technicians from the British government spy agency GCHQ, the journalists took angle-grinders and drills to the internal components, rendering them useless and the information on them obliterated.

The bizarre episode in the basement of the Guardian's London HQ was the climax of Downing Street's fraught interactions with the Guardian in the wake of Snowden's leak – the biggest in the history of western intelligence. The details are revealed in a new book – The Snowden Files: The Inside Story of the World's Most Wanted Man – by the Guardian correspondent Luke Harding. The book, published next week, describes how the Guardian took the decision to destroy its own Macbooks after the government explicitly threatened the paper with an injunction.

In two tense meetings last June and July the cabinet secretary, Jeremy Heywood, explicitly warned the Guardian's editor, Alan Rusbridger, to return the Snowden documents.

Heywood, sent personally by David Cameron, told the editor to stop publishing articles based on leaked material from American's National Security Agency and GCHQ. At one point Heywood said: "We can do this nicely or we can go to law". He added: "A lot of people in government think you should be closed down."

Downing Street insiders admit they struggled to come to terms with Snowden's mega-leak, and the fact that the 29-year-old American was able to upload top secret British material while working at an NSA facility in faraway Hawaii. Snowden wasn't even a full-time NSA employee, but a private contractor, one of 850,000 Americans with access to top secret UK information. "We just sat up and thought: 'Oh my God!'" one Downing Street insider said.

Some five weeks after Snowden first leaked classified NSA and GCHQ material, the British government still had no clue of the scale of the security breach. It was working on the assumption that a small amount of material had been lost.

A small team of trusted senior reporters examined Snowden's files in a secure fourth-floor room in the Guardian's King's Cross office. The material was kept on four laptops. None had ever been connected to the internet or any other network. There were numerous other security measures, including round-the-clock guards, multiple passwords, and a ban on electronics.

The government's response to the leak was initially slow – then increasingly strident. Rusbridger told government officials that destruction of the Snowden files would not stop the flow of intelligence-related stories since the documents existed in several jurisdictions. He explained that Glenn Greenwald, the Guardian US columnist who met Snowden in Hong Kong, had leaked material in Rio de Janeiro. There were further copies in America, he said.

Days later Oliver Robbins, the prime minister's deputy national security adviser, renewed the threat of legal action. "If you won't return it [the Snowden material] we will have to talk to 'other people' this evening." Asked if Downing Street really intended to close down the Guardian if it did not comply, Robbins confirmed: "I'm saying this." He told the deputy editor, Paul Johnson, the government wanted the material in order to conduct "forensics". This would establish how Snowden had carried out his leak, strengthening the legal case against the Guardian's source. It would also reveal which reporters had examined which files.

With the threat of punitive legal action ever present, the only way of protecting the Guardian's team – and of carrying on reporting from another jurisdiction – was for the paper to destroy its own computers. GCHQ officials wanted to inspect the material before destruction, carry out the operation themselves and take the remnants away. The Guardian refused.

After the destruction on Saturday 20 July, reporting switched entirely to the US. Despite these tensions, the paper continued to consult with the government before publishing national security stories. There were more than 100 interactions with No 10, the White House and US and UK intelligence agencies.

The hard drives used to store documents leaked by Edward Snowden are destroyed in the basement of the Guardian's London offices. Photograph: Guardian

Three Guardian staff members – Johnson, executive director Sheila Fitzsimons and computer expert David Blishen – carried out the demolition of the Guardian's hard drives. It was hot, sweaty work. On the instructions of GCHQ, the trio bought angle-grinders, dremels – a drill with a revolving bit – and masks. The spy agency provided one piece of hi-tech equipment, a "degausser", which destroys magnetic fields, and erases data. It took three hours to smash up the computers. The journalists then fed the pieces into the degausser.

Two GCHQ technical experts – "Ian" and "Chris" – recorded the process on their iPhones. Afterwards they headed back to GCHQ's doughnut-shaped HQ in Cheltenham carrying presents for family members, bought on their rare visit to the capital.

"It was purely a symbolic act," Johnson said. "We knew that. GCHQ knew that. And the government knew that," He added: "It was the most surreal event I have witnessed in British journalism."

The Snowden Files includes fresh details of Snowden's early life, his time in the CIA, and the libertarian ideas and political views which shaped his philosophy and his life-changing decision to spill government secrets. Snowden visited the UK several times during his intelligence career, including when he worked for the CIA at the US embassy in Geneva.

On one occasion he visited RAF Croughton, the CIA communications base 30 miles north of Oxford in Northamptonshire. Posting on the technology forum Ars Technica, Snowden said he was struck by the large number of sheep grazing in green fields – a classic English scene. On another occasion he flew to City airport in London. He said he was unimpressed by east London's multiracial neighbourhoods, telling one British user of the forum: "It's where all of your Muslims live. I didn't want to get out of the car."

The book also reveals that the British security service MI5 was behind the controversial detention of David Miranda, Greenwald's partner, at Heathrow airport last August. Miranda was detained under schedule 7 of the UK's Terrorism Act 2000, despite having no connection to terrorism. He was carrying heavily encrypted Snowden material at the time. MI5 tried to conceal its role in the affair, telling the police at Heathrow in a briefing: "Please do not make any reference to espionage activity. It is vital that MIRANDA is not aware of the reason for this ports stop."

• Read an exclusive extract from Luke Harding's The Snowden Files: The Inside Story of the World's Most Wanted Man in Weekend magazine and online on Saturday.