Some of the legal knots resulting from the march to war in Iraq are taking time to tease out. In the US, none may have greater long-term significance for the press than the fight between federal prosecutors and jounalists from the New York Times and Time that's now making it's way through the appeals courts.

At a minimum, the two journalists at the centre of the case, The New York Times' Judith Miller and Time's White House correspondent Matthew Cooper, face 18-month sentences for refusing to reveal their sources to investigators looking into the politically-motivated leaking of an undercover CIA officer's name to the media. In the extreme, the case may come to redefine the level of legal protection afforded US journalists who maintain the confidentiality of sources who are under government investigation.

The background to the case is well-known. In early 2001, the CIA sent a former US ambassador, Joseph Wilson, to Niger to investigate claims it had exported uranium to Iraq. When Wilson later published a report alleging that President Bush had exaggerated the evidence to justify his invasion of Iraq, his wife, Valerie Plame, was exposed as a CIA operative. The leak came from within the Bush administration, in what is widely seen as retribution for Wilson's criticism.

For two years, prosecutors have sought to establish who leaked Plame's identity to right-wing columnist Bob Novak (the finger of blame seems to point to someone in Vice-President Dick Cheney's office). No charges have been brought over the leak itself; only against Miller and Cooper for refusing to cooperate with a jury convened to hear prosecutors' evidence before bringing any charges.

Two weeks ago, the two journalists lost a judgement before a three-judge appeals court, which said that they were not protected from being compelled to give evidence about their sources. But last week, a federal judge ruled that prosecutors could not sequester their phone records in an attempt to find the leak. The toing and froing of rulings reflects the confusion as to whom and what is protected under the First Amendment.

Since 1961, 25 US journalists have been jailed for withholding information. Most recently, freelance writer Vanessa Leggett served 5 1/2 months in 2001 after refusing to reveal the source of information she used in a book about a Texas man acquitted of hiring someone to kill his wife.

But this may not be the best case to test a grey area of a law that largely favours the right of journalists to protect their sources over prosecutors investigating crimes. The guidelines instruct prosecutors not to pursue reporters, except in the most pressing circumstances. "The danger is that this case may do more damage to the privilege of the press than if they left it alone," says Douglas McCollum of the Columbia Journalism Review.

Under a complex law designed and passed to stop the activities of a renegade ex-CIA agent named Philip Agee in the eary 1980s it's not clear even whether a crime was committed when Plame was publicly outed by Novak. "It could be Miller and Cooper end up going to jail but nobody else does," McCollum says.

The case is full of ironies. Judith Miller, who was prominent among the journalists who were given - and who published - misleading pre-war information about Saddam Hussein's WMD program by Ahmed Chalabi, did not publish her story, which was based on conversations with a "specified government official" who was looking to expose Plame.

Arthur Sulzberger Jr, publisher of The New York Times, says: "If Judy is sent to jail for not revealing her confidential sources for an article that was never published, it would create a dangerous precedent that would erode the freedom of the press."

The uncertainties of the case are compounded by the intentions of Patrick Fitzgerald, the special prosecutor assigned to the case. When it began, the then Attorney General John Ashcroft was pressured to remove himself from any role in the investigation, which he did. His successor, Alberto Gonzalez citing similar ties to the White House, did the same. But the desired effect - an aggressive prosecution of leakers within the Bush administration - has yet to transpire. So far it has been about the pursuit of reporters and their sources. It may yet turn out to be a case both sides, the press and the government, wish they hadn't fought.

Still, as Norman Pearlstine, editor-in-chief of Time Inc., said last week: "In the United States no journalist should have to go to jail simply for doing his or her job."