FEW ASPECTS of the struggle between the United States and al-Qaeda have proved more contentious than the issue of whether, and under what circumstances, the U.S. military can detain suspected members of terrorist groups. To cut a very long and complex story short, there is a tension between upholding individual constitutional rights on the one hand and prosecuting a war against dangerous forces that, by definition, do not wear uniforms or carry arms openly. Some questions are clear — the impermissibility of torture, for example. But others, such as the precise definition of a person subject to military detention, are subject to legitimate disagreement.

The National Defense Authorization Act, adopted at the end of 2011, incorporated a hard-fought compromise on that point: It permitted, but did not require, military detention — with appropriate protections for their rights — of members of al-Qaeda or the Taliban, as well as persons who “substantially supported” such groups.

This formulation essentially codified authority that the Obama administration had long claimed under the 2001 congressional resolution authorizing the use of military force against the authors of the Sept. 11 attacks; it also corresponded roughly to language that the U.S. Court of Appeals for the D.C. Circuit had approved.

There were still ambiguities in the law; though it preserved the option to hold detainees in civilian custody, it arguably gave the government incentives to hold them in military custody. What was new and valuable, though, was that, after nearly a decade of hesitation, Congress, in dialogue with the executive branch, had lent its authority to a definition — as opposed to leaving the job up to the executive and the courts.

But instead of celebrating the fact that the legislation put detention law on a more solid statutory footing, critics of the bill attacked its supposed legalization of military arrests of those who merely associated with terrorists — or even journalists who treat them as protected sources.

One such group went to federal court in Manhattan with its claims that the law was so unconstitutionally vague that it had already deterred them from writing and speaking freely. Alas, on Wednesday, Judge Katherine B. Forrest brushed aside the Obama administration’s assurances and declared the portion of the statute authorizing detentions for “substantial” supporters of al-Qaeda and “associated forces” unconstitutional.

Judge Forrest protested that she was exercising appropriate deference to an act of Congress, but her uncritical acceptance of the plaintiffs’ claims — and equally summary dismissal of the administration’s protestations of good faith — smack of judicial activism. When constitutional rights are actually endangered, the federal courts should be vigilant. But Judge Forrest’s ruling, issued before any individual had been so much as threatened with detention, let alone actually detained, strikes us as an overreaction. May the administration’s appeal of the judge’s ruling prosper.