The National Security Agency has collected millions of Americans’ phone records under a program the Obama administration has said was authorized by Congress. (Patrick Semansky/AP)

A federal appeals court ruled Thursday that the National Security Agency’s collection of millions of Americans’ phone records violates the USA Patriot Act, marking the first time an appellate panel has weighed in on a controversial surveillance program that has divided Congress and ignited a national debate over the proper scope of the government’s spy powers.

In a blistering 97-page opinion, a unanimous three-judge panel of the U.S. Court of Appeals for the 2nd Circuit overturned a lower court and determined that the government had stretched the meaning of the statute to enable “sweeping surveillance” of Americans’ data in “staggering” volumes.

The ruling comes as Congress begins a contentious debate over whether to reauthorize the statute that underpins the NSA program or let it lapse. The court did not issue an injunction ordering the program to stop.

The NSA’s mass collection of phone records for counterterrorism purposes — launched after the Sept. 11, 2001, terrorist attacks — was revealed by former agency contractor Edward Snowden in June 2013. The revelation sparked outrage but also steadfast assertions by the Obama administration that the program was authorized by statute and deemed legal by a series of federal surveillance court judges.

But the judicial rulings had taken place in secret until the Snowden leaks forced disclosure of once-classified opinions. Under the program, the NSA collects “metadata” — or records of times, dates and durations of all calls — but not call content.

The government has argued that huge volumes of records — being collected from U.S. phone companies each day and stored in a database — are relevant to counterterrorism investigations because any record could later prove critical in identifying terrorism suspects. A series of judges on the secretive Foreign Intelligence Surveillance Court have agreed.

The appeals court, however, said “such an expansive concept of ‘relevance’ is unprecedented and unwarranted.”

In the ruling, written by Judge Gerard E. Lynch, the panel noted that the government never “attempted to identify to what particular ‘authorized investigation’ ” the data of all Americans’ phone calls would be relevant. “At its core,” the panel said, “the approach boils down to the proposition that essentially all telephone records are relevant to essentially all international terrorism investigations.” 

Saying the collection has amounted to “an unprecedented contraction of the privacy expectations of all Americans,” the court said the government’s interpretation of the law would also allow for the bulk collection and storage of data associated with Americans’ financial records, medical records, and e-mail and social-media communications.

With the statute scheduled to expire June 1, a bipartisan coalition of lawmakers in the House and Senate is seeking to renew it with modifications that sponsors say will enable the NSA to get access to the records it needs while protecting Americans’ privacy. The bill, the USA Freedom Act, is poised to pass the House next week.

Meanwhile, Senate Majority Leader Mitch McConnell (R-Ky.) and the chairman of the Senate Intelligence Committee, Richard Burr (R-N.C.), have introduced a bill to maintain the program. But if that passes, the government will have to persuade the Supreme Court to reverse the 2nd Circuit decision in order to keep the program from ending.

The court decision drew sharp responses from some Republicans on the Senate floor Thursday.

“According to the CIA, had these authorities been in place more than a decade ago, they would have likely prevented 9/11,” McConnell said. He said the USA Freedom Act would not “keep us safe or protect our privacy.”

Meanwhile the bill’s sponsors — Sens. Patrick J. Leahy (Vt.), who is the ranking Democrat on the Judiciary Committee, and Mike Lee (R-Utah) — issued a statement saying: “Congress should not reauthorize a bulk collection program that the court has found to violate the law. We will not consent to any extension of this program.”

FBI Director James B. Comey told reporters that if Congress lets the statute, known as Section 215 of the Patriot Act, expire, the FBI will lose a useful tool. “But,” he said, if that was to happen, “we press on.”

Administration officials have indicated they are likely to support the bipartisan legislation. But the American Civil Liberties Union and a coalition of groups on the left and the right are pushing to let the statute simply lapse, on grounds that it would end the NSA bulk collection while leaving in place adequate powers for the government to pursue terrorism cases.

The appeals court, noting the impending deadline for the program, declined to grant a preliminary injunction to stop the NSA from collecting the ACLU’s call records. “In light of the asserted national security interests at stake, we deem it prudent to pause to allow an opportunity for debate in Congress that may (or may not) profoundly alter the legal landscape,” Lynch wrote.

The ACLU, the plaintiff in the case, cheered the decision.

“This decision is a resounding victory for the rule of law,” said ACLU staff attorney Alex Abdo, who argued the case before the panel in September. “For years, the government secretly spied on millions of innocent Americans based on a shockingly broad interpretation of its authority. The court rightly rejected the government’s theory that it may stockpile information on all of us in case that information proves useful in the future.”

White House officials said Thursday that they were evaluating the decision and declined to comment further.

“The president has been clear that he believes we should end the Section 215 bulk telephony metadata program as it currently exists by creating an alternative mechanism to preserve the program’s essential capabilities without the government holding the bulk data,” said Edward Price, a National Security Council spokesman. “We continue to work closely with members of Congress from both parties to do just that, and we have been encouraged by good progress on bipartisan, bicameral legislation that would implement these important reforms.”

The ruling has scrambled the terms of the debate, strengthening the hand of those who want changes that go further than those called for in the USA Freedom Act, said civil liberties advocates. “The people who supported the current version of USA Freedom should start asking for more, because we can get more now,” said Jennifer Granick, director of civil liberties at Stanford Law School’s Center for Internet and Society.

David O’Neil, a former acting head of the Justice Department’s Criminal Division, said the ruling “seriously upsets the apple cart three weeks before the sunset.”

The issue is one that has split lower courts. The U.S. District Court for the District of Columbia held in December 2013 that the program was probably unconstitutional. The appeals court for the District has not yet ruled on that appeal.

In its ruling, the U.S. Court of Appeals for the 2nd Circuit said it need not address the plaintiffs’ claims that the NSA program violated their First and Fourth amendment rights, because the panel had already concluded the program was unlawful. The court rejected the government’s argument that Congress ratified the program by twice reauthorizing Section 215, noting that many members and the public were unaware of how the legislation was being interpreted. It also rejected the government’s argument that the ACLU lacked standing to challenge the program.

Thursday’s ruling was “sweeping and unambiguous,” said Michael Sussmann, a former Justice Department official who is now a partner at Perkins Coie practicing surveillance law. “As the deadline quickly approaches, this is a bombshell that forces everyone to reconsider the political fault lines.”

Adam Goldman contributed to this report.