A federal judge in New York has ruled that the National Security Agency (NSA) has the legal right to collect metadata on phone calls made within the United States. In so doing, Judge William H. Pauley III of the U.S. District Court for the Southern District of New York dismissed a legal challenge to the NSA’s surveillance activities by the American Civil Liberties Union (ACLU). It also counters an earlier ruling, by Judge Richard Leon of the Federal District Court for the District of Columbia, that found the NSA’s metadata collection unconstitutional. Pauley cited the need to effectively fight terrorism as his chief motivation behind the ruling. “Technology allowed al-Qaeda to operate decentralized and plot international attacks remotely,” he wrote in the lengthy ruling (PDF; hat tip to The Verge for posting it). “The bulk telephony metadata collection program represents the government’s counter-punch: connecting fragmented and fleeting communications to re-construct and eliminate al-Qaeda’s terror network.” He added: “There is no evidence that the Government has used any of the bulk telephony metadata it collected for any purpose other than investigating and disruptive terrorist attacks.” At the same time, however, he also acknowledged NSA employees’ occasional violations of security and privacy guidelines, which he framed as “unintentional” and appearing to stem “from human error and the incredibly complex computer programs that support this vital tool.” Despite the ruling, it’s likely this legal fight over NSA metadata will continue onwards, as the ACLU will almost certainly appeal—whether it reaches as far as the U.S. Supreme Court remains to be seen. In June, government whistleblower Edward Snowden began feeding top-secret NSA documents (downloaded while he served as a system administrator at an agency outpost in Hawaii) to The Guardian and other newspapers. Many of those documents detailed the NSA’s metadata program, and ignited a firestorm of controversy. In response, President Barack Obama announced earlier this month that he plans on reining in the NSA’s surveillance programs, but won’t reveal exact steps until 2014.   Image: Brian A Jackson/Shutterstock.com