WASHINGTON — The National Security Agency's mass collection of telephone data does not violate the constitution, a federal judge in New York has ruled, creating a conflict within the federal courts and increasing the likelihood that the Supreme Court eventually will have to resolve the program's fate.

The decision Friday by U.S. District Judge William H. Pauley will bolster the position of the NSA and its allies just as President Obama is considering whether to impose new restrictions on the spy agency's activities.

Pauley called the NSA's surveillance programs part of the "the government's counterpunch" against the Sept. 11, 2001, attacks, which he said happened in part because of a failure to "connect the dots" linking terrorists.

Edward Snowden: An article in the Dec. 28 Section A about a judge's ruling that the National Security Agency's mass collection of telephone data is legal contained a photo of Edward Snowden, a former contractor for the NSA. The photo caption incorrectly referred to him as Eric Snowden. —

"The government learned from its mistake and adapted to confront a new enemy, a terror network capable of orchestrating attacks across the world," he wrote.

At issue is the NSA's collection of "metadata" — information such as which numbers are called from other numbers and how long the calls last — from virtually all telephone calls made within or from the U.S.

While that data collection is vast, Pauley said, a previous Supreme Court ruling has made clear that the 4th Amendment does not protect information that a person turns over to someone else, including a telephone company.

"When a person voluntarily conveys information to a third party, he forfeits his right to privacy in the information," Pauley wrote.

Less than two weeks ago, the NSA's critics celebrated a victory in federal court as a district judge in Washington, D.C., ruled that the wholesale collection of metadata did violate the Constitution's ban on unreasonable searches.

Both rulings are certain to be appealed — the Washington decision to the D.C. Circuit Court of Appeals and Pauley's to the New York-based 2nd Circuit. Ultimately, whichever side loses in the appeals courts probably will ask the Supreme Court to rule on the issue.

In the meantime, as the president ponders whether to adopt any of the 46 changes in the NSA's programs recommended by a review panel he appointed, the two rulings will give him and other participants in the debate two sharply contrasting judicial assessments of how to balance privacy rights with security concerns.

The two rulings are "like night and day," said Jonathan Hafetz, a law professor at Seton Hall University in New Jersey.

Pauley, a onetime Republican official in New York who was appointed to the federal bench by President Clinton, suggested in his ruling that the deaths on Sept. 11 might have been prevented had mass collection of telephone data been in place at the time.

By contrast, District Court Judge Richard J. Leon, who was appointed by President George W. Bush, had questioned the utility of the NSA's data collection program, saying that "the government does not cite a single instance in which analysis of the NSA's bulk data collection actually stopped an imminent attack."

Leon described the NSA's collection of telephone data as an "indiscriminate and arbitrary invasion" of the 4th Amendment's protection from unreasonable searches. He called the NSA's vast database of telephone call records an almost "Orwellian technology."

Pauley, by contrast, said the NSA's collection did not violate any constitutional rights. He relied on a 1979 Supreme Court precedent — one that Leon had brushed aside as outdated — for his ruling that the 4th Amendment does not protect the information at issue.

The huge scale of the NSA's activities does not change the legal analysis, Pauley said.

"The collection of breathtaking amounts of information unprotected by the 4th Amendment does not transform that sweep into a 4th Amendment" violation, he wrote.