The Milly Dowler phone hacking story prompted the closure of the News of the World, the resignation of Rebekah Brooks and is expected to lead to a near £3m apology payout to the family involved.

Yet, when officers from the Metropolitan police came to the Guardian last week, they offered a different view: that it was not an example of journalism in the public interest, but, in effect, a product of espionage.

The officers demanded evidence – specifically notebooks and other information held by Guardian journalist Amelia Hill, one of the authors of the Milly Dowler story, in an effort to discover its source.

Their claim was that that article, and others about Operation Weeting, the police investigation into phone hacking, had been one of a number of "gratuitous" leaks from the enquiry team.

Indeed, so gratuitous were the leaks that the police demand for evidence indicated they believed there may have been a breach under the Official Secrets Act.

The demand was so unusual that it was not just the Guardian that was scrambling to comprehend the law. The police demand for evidence, a production order under the Police and Criminal Evidence Act (Pace), came with the allegation that there were breaches of the obscure sections 4 and 5 of the Official Secrets Act.

The right to preserve the anonymity of sources is enshrined in law, and there is a public interest defence against a (normal) Pace order. But there is no public interest defence to breaches of the Official Secrets Act. Lawyers have speculated that the almost unprecedented use of section 5 of the Official Secrets Act was to bolster the Met's argument for seizing the reporter's notebooks and records

The results were all too predictable. Last Friday, the Guardian went public, revealing that the police had asked for a court ruling on the legality of the demand this Friday. Remarkably, support for the newspaper was widespread, with trenchant leading articles from the Financial Times and the Daily Mirror, which both recognised the importance of protecting journalistic sources. Meanwhile the Sunday Times, part of Rupert Murdoch's media stable, called on the Met to "call off its legal dogs". Even Richard Littlejohn, the Daily Mail columnist, announced, after advising his readers to "pour yourself a stiff drink", that he was "about to defend the Guardian" in a column.

Politicians swiftly joined in. At their party conference, the Liberal Democrats were quick to voice support; asked by MP Don Foster at a fringe meeting attended by Hugh Grant whether there was a public interest in publishing the Milly Dowler story, every one of the 200 or so hands went up. On Monday, Labour followed suit – and both parties called on politicians or senior officials to intervene. As Fleet Street rallied around and politicians followed, the authorities struggled.

So obscure are Sections 4 and 5 of the Official Secrets Act that the office of the attorney general, Dominic Grieve, thought it had the power to review whether a prosecution under the act would be brought if the Guardian refused to comply with the request to produce evidence.

In fact, the power as regards section 4(2) [see footnote] lies with Keir Starmer, the director of public prosecutions, and it turned out that the police had failed to inform his officials until Monday.

It was unclear, also, whether the new Met commissioner, Bernard Hogan-Howe, was aware of his officers' threat to use the Official Secrets Act. Only days into his tenure, and the new commissioner suddenly found his force embroiled in an unnecessary controversy over the same issue that had forced the resignation of his predecessor, Sir Paul Stephenson.

Ultimately, it was understood Hogan-Howe was not aware; that the request, it appeared, had come from a relatively junior level – although that did not mitigate the force or importance of the demand.

Under such public pressure, the police decision to retreat is a relief. Through brilliant – or diabolical – legalism, the Met appeared to find a way to tear up the rights of journalists to protect their sources.

That the Met chose not to proceed might deny a judge the chance to rule on a test case, but it is better to avoid setting a precedent if that precedent would have had the effect of putting every whistleblower from the public sector at risk of exposure, because they could be deemed to have breached the Official Secrets Act.

• This article was amended on 21 September 2011. The story incorrectly stated that the consent of the director of public prosecutions (DPP) is necessary for a prosecution under sections 4 and 5 of the OSA. The DPP's consent is required only for section 4(2), which applies to someone who is, or has been, a Crown servant or govenment contractor and deals with disclosure of information. For all other prosecutions under the act the attorney general's approval is needed.