LONDON — A British court ruled Thursday 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 organizations 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.