A British court ruled on Thursday (local time) that the bulk of a terrorism trial can be held in secret on national security grounds, but rejected prosecutors' attempt to impose secrecy on the entire case, from the selection of the jury to the identity of the defendants.
Media organisations had argued that would be a first in British legal history, and a dangerous precedent.
The case concerns two men who were arrested last year and charged with terrorism offenses. Prosecutors argued they would have to abandon the case if the trial could not be held in private and without naming the defendants.
Last month a judge agreed to the restrictions, but the ruling was challenged by the BBC and other media organisations. Their lawyer, Anthony Hudson, called the secrecy bid a "totally unprecedented departure from the principle of open justice."
On Thursday (local time) three appeals judges ruled that the case was "exceptional," and that the core of the trial should be heard without the public present. They said they were convinced that "the administration of justice would be frustrated if the trial were to be held in open court."
But, in a victory for the media, they said some sections would be held in public, including the jury swearing-in, the reading of the charges, part of the prosecution's opening statement and the verdicts.
A small number of journalists will be allowed to attend most of the proceedings, but not to report on them as they unfold. They will be subject to strict restrictions, including leaving their notebooks behind at the end of each day, and will not be able to report on the trial until a new court order is given.
The judges expressed "grave concern" about combining closed hearings with anonymous defendants, and ordered that the names of the suspects be released.
The defendants, previously named as AB and CD, were then identified as Erol Incedal and Mounir Rarmoul-Bouhadjar. Incedal is charged with preparing an act of terrorism and possessing bomb-making instructions and Rarmoul-Bouhadjar with possessing the instructions and false identity documents. Details of their alleged crimes have not been made public.
British judges often impose reporting restrictions while trials are underway, usually to avoid prejudicing future proceedings, and portions of trials have previously been held without press or public present. But lawyers said an entire secret criminal trial was unprecedented.
Lord Justice Peter Gross, one of the appeal judges, said that open justice was "a fundamental principle of the common law," but restrictions were justified in some circumstances.
"Exceptions are rare and must be justified on the facts," he said.
Other democracies, including the United States, have grappled with balancing security and open trials in cases connected to terrorism or intelligence.
Several suspects in the September 11 terrorist attacks are being tried before a military commission at the Guantanamo Bay detention center in Cuba after being declared "enemy combatants."
A special US federal court, the Foreign Intelligence Surveillance Court, hears applications for surveillance warrants. Its secrecy-shrouded work has been the subject of intense interest since the scale of those requests was disclosed by former National Security Agency contractor Edward Snowden.
The Crown Prosecution Service said it accepted the British court's decision.
Isabella Sankey, director of policy for human-rights group Liberty, said she was glad that "faced with a blacked-out trial we now have a few vital chinks of light."
"But (the judges') wholesale deference to vague and secret ministerial 'national security' claims is worrying," she said. "Shutting the door on the core of a criminal trial is a dangerous departure from our democratic tradition."
The trial is due to start next week.