The federal government's bulk collection of Americans’ telephone records after the Sept. 11 attacks exceeds what Congress has allowed, a federal appeals court ruled Thursday.

A three-judge panel of the 2nd U.S. Circuit Court of Appeals in Manhattan said the case, brought by the American Civil Liberties Union, illustrated the complexity of balancing privacy interests with the nation's security.

A lower court judge had thrown out the case, but the appeals court said the lower court erred in ruling that phone record collection by the National Security Agency (NSA) was legal.

The 2nd Circuit, however, declined to block the collection of phone records under the NSA program, saying it is now up to Congress to decide whether and under what conditions it should continue.

“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,” said the opinion written by Circuit Judge Gerald Lynch.

The ACLU welcomed the decision, calling it a “resounding victory for the rule of law.”

“For years, the government secretly spied on millions of innocent Americans based on a shockingly broad interpretation of its authority,” ACLU staff attorney Alex Abdo, who argued the case before the three-judge panel in September, said in a statement. “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. Mass surveillance does not make us any safer, and it is fundamentally incompatible with the privacy necessary in a free society.”

The 2nd Circuit court said a debate in Congress could profoundly alter the legal landscape, although the ACLU expressed doubt that Washington could address the concerns raised by the court.

“The current reform proposals from Congress look anemic in light of the serious issues raised by the 2nd Circuit,” said Anthony D. Romero, the executive director of the ACLU. “Congress needs to up its reform game if it’s going to address the court’s concerns.”

Rep. Adam Schiff, the ranking Democrat on the House Intelligence Committee, said he hopes the ruling serves as a “catalyst for an end to bulk collection and the beginning of serious reform.”

Thursday’s decision vacated a December 2013 dismissal of an ACLU lawsuit contending that the NSA’s collection of bulk telephone metadata violated the prohibition of warrantless searches under the Fourth Amendment.

“For more than seven years, the government has collected the phone records of every American under Section 215 of the Patriot Act, without ever having to justify the program’s legality in a public and adversarial court hearing,” Brett Max Kaufman, a legal fellow with the ACLU National Security Project, wrote for the ACLU blog after the lawsuit was filed in November 2013.

Since 2006, the NSA program has been amassing “an enormous database of some of the innermost details of our private lives ... In the aggregate, metadata can expose a ‘startlingly detailed’ [PDF] profile of each and every American’s life — for example, her religion, political associations, contemplation of suicide, addictions to gambling or drugs, experience with rape or difficulties struggling with sexuality,” he wrote.

Thursday’s ruling sharpens the focus on the ongoing congressional debate about whether to end NSA’s collection of phone records as part of a Patriot Act reauthorization. The provisions that authorize the phone records program are among those that expire June 1.

Republicans and Democrats in the House have agreed on a bill to end the government’s bulk collection of the records, but Senate leaders are backing a competing measure that would maintain the status quo. One of the sponsors, Intelligence Committee chairman Richard Burr, has said he is open to a compromise, however.

The divisions on the issue don’t run neatly along partisan lines. Libertarian-leaning Republicans have joined many Democrats in arguing that a secret intelligence agency should not be storing the records of every American phone call, even if the data are examined only under limited circumstances. Some Democrats and Republicans assert that the program is needed now more than ever, given efforts by the Islamic State in Iraq and the Levant to inspire extremists to attack in the U.S.

The House Judiciary Committee last month overwhelmingly voted to advance the latest version of a bill known as the USA Freedom Act. The measure seeks to codify President Barack Obama’s proposal to end the NSA’s collection and storage of the phone records and allow the agency to request records held by telephone companies under a court order in terrorism investigations.

Former contractor Edward Snowden leaked secret NSA documents to journalists in 2013 that revealed it was collecting phone records and digital communications of millions of citizens not suspected of crimes.

Al Jazeera and wire services