It is an age-old journalistic dilemma: the reporter discovers information that he or she believes is in the public interest to disclose, but the government says lives will be put at risk by doing so.

To publish or not to publish? How do editors and reporters make that decision? How did journalists make it when working on the Afghan war logs published by the Guardian a fortnight ago?

The logs are tens of thousands of internal US tactical reports by troops operating in Afghanistan between January 2004 and December 2009. The detailed background to the acquisition of the 92,000 documents can be found here and here.

The Guardian, along with the New York Times and Der Spiegel, spent weeks deploying teams of journalists to comb through the raw material of the documents, which were eventually published on WikiLeaks. Each approached the task slightly differently.

There was immediate criticism from both governments and individuals of publication. Critics focused on the risk to soldiers on the ground and those Afghans who have co-operated with Nato forces. Much of the anger came from other newspapers, but the Guardian has received only two complaints from readers who believed we were wrong to publish.

For David Leigh, the Guardian's head of investigations, the issue was simple: "We always erred on the side of caution and we believe we didn't run anything that endangered individuals' lives."

Nick Davies, who brokered the deal to gain access to the WikiLeaks documents, is equally adamant:

"The first time I spoke to Julian Assange [the founder of WikiLeaks] in Brussels in mid-June, before I saw the documents I said there are two issues: one, there may be nothing of interest here, and two, there must be a risk that publication would put people on the ground at risk. There was always a big shining light on that right from the outset. It's not our job to get people killed and I am not interested in publishing anything that might get someone killed.

"There were 92,000 documents and we published fewer than 300 of them. Each one was read from top to toe with the conscious aim of excluding anything that might endanger people on the ground.

"You can't have governments decide what should be published and what shouldn't, therefore we, as journalists, have to make our own judgments."

The documents themselves were classified as "secret" in the US. The equivalent in the UK is "confidential". That is lower than a "top secret" classification in the UK.

At the New York Times, where the US-based American journalists have the benefit of the first amendment – a key section of which is: "Congress shall make no law ... abridging the freedom of speech, or of the press" – they nevertheless took a slightly different approach.

Eric Schmitt, one of the authors of the NYT piece said:

"I can't speak for the newspaper as a whole, but I've received a handful of emails complaining about this point so I expect we've received several complaints.

"On this story, as with all sensitive military/ intelligence/ national security articles, we took great care to mitigate any threat to US service members, Afghan security forces and informants working with the US in Afghanistan; as well as US national security, and sensitive sources and methods. We redacted [removed] the names and other identifying details from the incident reports we published in the Times. Before publication, we asked the White House, CIA and Defense Department if they had any objections to specific information being made public. They had a couple of specific requests, which we honoured because we did not feel their omission would lessen the impact of the articles. Since publication, we have not received any specific complaints on this point from the Pentagon."

In the UK, newspapers are encouraged to approach the defence press and broadcasting advisory commitee (DPBAC), which is not part of the Ministry of Defence but is nevertheless chaired by the permanent undersecretary of state for defence. The role of the committee, which has press and broadcasting members but no one from the Guardian, is to advise publications on matters of national security. Journalists don't have a legal obligation to take the advice. The Guardian's legal advice was quite clear that it faced potential actions by the US government under the US Espionage Act and the UK's Official Secrets Act. Not much incentive to go to the DPBAC then?

Air Vice-Marshal Andrew Vallance is the DPBAC secretary. If we had taken the documents to his committee he says he would not have felt obliged to tell the MoD and thus potentially trigger an injunction, which was a very real fear for the Guardian's editor, Alan Rusbridger.

Valance said: "I am independent of the MoD and any advice I offer [to media organisations] is always given in strictest confidence. However if I was faced with an issue where I believe someone's life was actually in danger I would have to think about breaking that confidence", said Air Vice-Marshal Vallance.

"As it was, I couldn't see anything in the Guardian's coverage which put lives directly at risk, but I understand why analysts believe that some agents may have been compromised [in the wider coverage]."

The Guardian has not been approached by either the US or UK government since publication.

Rusbridger confirmed that discussions about the risk to soldiers and Afghans as a result of publication were part of the investigation from the beginning.

"We had a lot of discussion about that. Our starting point was that we were not going to just put things out there. The alternative was just a gigantic dump of raw information. I think that what we have done is a good thing, not a bad thing. We were very careful to do our best to put it in context, treat it with caution. If you read the coverage, particularly Declan Walsh's piece, you can see that there was real scepticism about the quality of some of that information. We were very careful to vet everything we published, using advice from regional specialists. We also tried to influence Julian Assange to redact names."

He said the fear of injunction should the Guardian approach any government agency or committee before publication meant that such an approach was out of the question.

"We satisfied ourselves that that we hadn't broken our own internal rules in the way we handled these documents. We generally don't identify serving intelligence operatives or their contacts, although you can never say never. I don't believe we have ever done so."

In fact that convention, however strongly embedded in the Guardian's approach to journalism, is not part of its editorial code of conduct although that code is currently under review. "Maybe we should codify it," said Rusbridger.

Isn't it arrogant for an editor to think that he or she is in a position to decide what would cause harm and what wouldn't? Rusbridger said:

"In the end you weigh up what you believe to be public good against public harm, you try to minimise the harm by highlighting public material of most public interest. You have a discussion about whether journalists should make those decisions but what it comes down to is whether you believe in the fourth estate.

Alternatively you leave these decisions to be taken by elected officials or parliament but I believe that would mean that virtually no material would be released."

Only the next few months will reveal whether we got the balance of risk right. Professionally there is no evidence that the reporters were other than scrupulous in minimising the risk. There may still be a risk, but when challenging authority, which has been the basis of the best Guardian journalism for nearly 190 years, you can't ask its leave to do so.

• This article was amended on 10 August 2010. The original referred to the Wikileaks documents' rating as "classified" in the UK. This has been corrected.

