The National Security Agency (NSA) phone data collection is illegal, a US appeals court has ruled.
Overturning a 2013 ruling, the judges did not, however, halt the program but urged Congress to take action.
The NSA’s spying was leaked by former contractor Edward Snowden, who has since fled to Russia.
The NSA has collected data about numbers called and times, but not the content of conversations. It also allegedly spied on European firms.
Among individuals targeted was German Chancellor Angela Merkel.
The latest verdict, by The 2nd US Circuit Court of Appeals in New York, came after New York District Judge William Pauley had dismissed a legal challenge by the American Civil Liberties Union (ACLU) which argued that the way the NSA tracked million of calls contravened the US constitution.
The 97-page ruling says that “a provision of the USA Patriot Act permitting the Federal Bureau of Investigation to collect business records deemed relevant to a counterterrorism investigation cannot be legitimately interpreted to permit the systematic bulk collection of domestic calling records”.
However, the appeals court stopped short of ruling on the constitutionality of the program, launched after the 11 September 2001 attacks on the US.
Edward Snowden’s revelations in June 2013 caused an international outcry, despite US administrations insisting the program has been fully authorized.
The measures – repeatedly approved in secret by a national security court since 2006 – are set to expire on June 1st.
Leaders of the lower US House of Representatives would prefer to pass a bill to end the government’s bulk collection of phone records and replace it with legislation that supporters say protects civil liberties. Republican Senate Majority Leader Mitch McConnell has indicated he wants to extend the Patriot Act and retain the bulk collection program.
The White House supports “an alternative mechanism to preserve the program’s essential capabilities without the government holding the bulk data”, said Ned Price, a spokesman for the White House National Security Council.
ACLU’s deputy legal director Jameel Jaffer said: “The appeals court’s careful ruling should end any debate about whether the NSA’s phone-records program is lawful.”