U.S. District Judge William Pauley said in a written opinion that the program "represents the government's counter-punch" to eliminate al-Qaida's terror network by connecting fragmented and fleeting communications.
In ruling, the judge noted the Sept. 11 terrorist attacks and how the phone data-collection system could have helped investigators connect the dots before the attacks occurred.
"The government learned from its mistake and adapted to confront a new enemy: a terror network capable of orchestrating attacks across the world. It launched a number of counter-measures, including a bulk telephony metadata collection program — a wide net that could find and isolate gossamer contacts among suspected terrorists in an ocean of seemingly disconnected data," he said.
Pauley's decision contrasts with a ruling earlier this month by U.S. District Court Judge Richard Leon, who granted a preliminary injunction against the collecting of phone records of two men who had challenged the program. The Washington jurist said the program likely violates the U.S. Constitution's ban on unreasonable search.
Pauley dismissed a lawsuit brought by the American Civil Liberties Union. The ACLU did not immediately respond to a message for comment.
"We are pleased with the decision," Justice Department spokesman Peter Carr said.
In arguments before Pauley last month, an ACLU lawyer had argued that the government's interpretation of its authority under the Patriot Act was so broad that it could justify the mass collection of financial, health and even library records of innocent Americans without their knowledge. A government lawyer had countered that counterterrorism investigators wouldn't find most personal information useful.
The ACLU sued earlier this year after former NSA analyst Edward Snowden leaked details of the secret programs that critics say violate privacy rights. The NSA-run programs pick up millions of telephone and Internet records that are routed through American networks each day.
Associated Press writer Mark Sherman contributed to this report.
Copyright 2013 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.