David B. Rivkin Jr. is co-chairman of the Center for Law and Counterterrorism at the Foundation for Defense of Democracies and a partner at Baker Hostetler. He served in the Justice Department during the Reagan and George H.W. Bush administrations and has represented the 26 states that have challenged the constitutionality of the 2010 Affordable Care Act. Charles D. Stimson, senior legal fellow at the Heritage Foundation, was a deputy assistant secretary for detainee affairs at the Defense Department during the George W. Bush administration.

The United States has just lost a key ally in the fight against al-Qaeda terrorists: the residents of Virginia, and state employees in particular.

Virginia’s legislature recently passed a bill that forbids state employees, including police and members of the National Guard, from participating in the investigation, surveillance, detention or arrest of any suspected member of al-Qaeda or its affiliates, if that suspect is a U.S. citizen.

The bill, which Gov. Robert F. McDonnell (R) signed Wednesday, is unconstitutional. It trenches on the federal government’s war powers and violates conditions under which Virginia and other states have received billions of dollars of federal funding. It has dangerous symbolic and practical consequences and undermines the cooperation necessary to disrupt and defeat al-Qaeda plots on our shores.

The basis of this legislation in Virginia and 11 other states (Arizona, Kansas, Maine, Maryland, Missouri, Oklahoma, Rhode Island, Tennessee, Utah, Washington and West Virginia) is a gross misunderstanding or intentional misreading of the detainee provisions in the 2011 National Defense Authorization Act (NDAA).

Some members of the tea party and the Tenth Amendment Center, a conservative group devoted to states’ rights, have joined with the American Civil Liberties Union to monger fear over federal detention authority. Under their contorted reading of the act, federal law requires all U.S. citizens suspected of terrorism to be held in military custody and strips them of all constitutional rights.

But although the NDAA describes military custody as the primary policy option for dealing with captured enemy combatants, the president retains, as is constitutionally proper, discretion to utilize the civilian justice and penal systems. In fact, the NDAA did not change settled law at all. It says that “nothing in this section shall be construed to affect existing law” related to the detention of U.S. citizens captured or arrested in the United States. Furthermore, under the Supreme Court’s post-Sept. 11 rulings, especially Hamdi v. Rumsfeld and Boumediene v. Bush , enemy combatants (regardless of citizenship) may be held for the duration of the hostilities, but anyone in military custody, whether in the United States or Guantanamo, is able to exercise habeas corpus rights to challenge the detention.

Despite these facts, some continue to fight what they see as a federal leviathan that acts extra-constitutionally all the time. But the federal government has the primary role in national security. Although comprehensive detention legislation has proved elusive, the language in the NDAA reflects the considered and constitutionally binding judgment of Congress and the president on an issue over which the federal government properly holds sway.

Since Sept. 11, 2001, al-Qaeda and its affiliates have recruited terrorists in the United States. Under the law of armed conflict — which predates the 2001 attacks — enemy combatants, regardless of citizenship, may be detained for the duration of the hostilities.

Virginia’s new law sends mixed messages to state employees, especially law enforcement officials. Imagine a state trooper pulling over a speeder and finding out through an ID check that the FBI has an alert for the driver as a suspected al-Qaeda operative. What should the trooper do if he knows or suspects the driver is a U.S. citizen? Do his duty and detain the suspect, which violates Virginia law? Or simply write the speeding ticket and send the driver on his way, not telling the FBI or the military, consequences be damned?

Although the federal government has no inherent constitutional right to compel state officials to help in combating al-Qaeda, since 9/11 it has funneled billions of dollars to all states that require fulsome cooperation from state law enforcement authorities. Meanwhile, state National Guard forces, when deployed overseas, are subject to federal control. For these reasons, Virginia’s legislation violates the federal law.

Beyond these practical concerns, Virginia’s legislation, especially if followed by more states, sends a powerful message that delegitimizes not just the military detention of captured enemy combatants but also the entire laws-of-war architecture. Legitimacy of government policies matters a great deal in our democracy. Unfortunately, it already was heavily battered, primarily by the left, during the George W. Bush administration.

The tea party members who are pushing for these state actions may not know that the Obama administration has, after some initial equivocation, endorsed the laws-of-war paradigm and has retained most of the Bush administration’s policies. This extremely positive development provides much-needed bipartisanship in this key area of national policy.

The Virginia legislation, and similar legislation in other states, violate the U.S. Constitution. It has nothing to do with states’ rights. It is a dangerous mistake, perpetrated by groups and people who misunderstand detainee law, including the NDAA, or who, since Sept. 11, have viscerally opposed the laws-of-war paradigm. Whatever their motivations, they are wrong, and their efforts should be strongly opposed.