The N.S.A. program that saw the agency collect millions of phone records across the country was illegal, a federal appeals court in Manhattan ruled on Thursday.

The Court of Appeals for the Second Circuit found that the N.S.A.’s phone tapping was illegal because it was not authorized by Congress. 

The phone tapping and other surveillance of Americans by the National Security Agency were first uncovered when former security contractor Edward Snowden leaked classified documents about the programs.

Thursday’s decision overrules a lower court’s finding in 2013 that dismissed the case - and opens up the possibility of a wider challenge to the N.S.A.’s methods.