The lives of British agents may have been put at risk by a Guardian journalist’s possession of top-secret documents stolen from the US government, the Daily Mail understands.

Documents seized from the reporter’s boyfriend, David Miranda, were so sensitive that agents have since had to be moved to protect their lives, sources said.

Court papers released yesterday also revealed the incredibly lax security used around the material, with Miranda apparently carrying a password for some of the computer documents written on a scrap of paper. Security sources also said that, as a result of the theft, codes for tens of thousands of sensitive documents have had to be changed.

Details of the chaos caused at the highest levels of Britain’s security and intelligence agencies by the leaks emerged in official court submissions about material seized from Miranda, the boyfriend of Guardian journalist Glenn Greenwald.

Miranda, 28, who is Brazilian, was detained at Heathrow on August 18 as he passed through the airport on his way from Berlin to Rio de Janiero.

He was found to be carrying nine hard disks and memory sticks including secret files leaked by ex-CIA analyst Edward Snowden, and was questioned for nine hours before being released. Miranda’s detention under terrorism powers provoked outrage from civil liberties groups.

Despite only decrypting one third of the material, police have already discovered 58,000 classified documents, many marked secret or top secret.

Oliver Robbins, deputy national security adviser, went on the record to warn that “lives may be put at risk” if the documents fall in to the wrong hands. He said the material was likely to contain details of secret techniques used to prevent terror attacks, personal information about agents at home and abroad and “other intelligence activities vital to UK national security”.

The release of the information could pose a “direct threat to the life of UK government employees”, as well as threaten the lives of their families, he said.

In a statement to the High Court, Mr Robbins warned the judges — who granted additional powers to the police to examine the classified material — that the information which had been decrypted “has had a direct impact on decisions taken in regard to staff deployments and is therefore impacting operational effectiveness”.

Alan Rusbridger, the editor of the Guardian, branded his claims “unsubstantiated and inaccurate”.

He said: “The Guardian took every decision on what to publish very slowly and very carefully and when we met with government officials in July they acknowledged that we had displayed a ‘responsible’ attitude.

“The Government’s behaviour does not match their rhetoric in trying to justify and exploit this dismaying blurring of terrorism and journalism.”