Washington (CNN) -- The National Security Agency notched a much-needed win in court Friday after a series of setbacks over the legality and even the usefulness of its massive data collection program.
A federal judge in New York ruled the NSA's bulk collection of data on nearly every phone call made in the United States was legal.
The ruling contrasts with another ruling last week by a federal judge in Washington, who called the same program "almost Orwellian" and likely unconstitutional.
In his ruling Friday, U.S. District Judge William Pauley said the NSA's bulk collection of phone records under Section 215 of the Patriot Act was legal. The program was revealed in classified leaks by former NSA contractor Edward Snowden.
"But the question of whether that program should be conducted is for the other two coordinate branches of government to decide," said the ruling by Pauley, an appointee of President Bill Clinton.
The American Civil Liberties Union, which brought the case, said it would appeal Pauley's ruling.
"We are extremely disappointed with this decision, which misinterprets the relevant statutes, understates the privacy implications of the government's surveillance and misapplies a narrow and outdated precedent to read away core constitutional protections," said Jameel Jaffer, the ACLU's deputy legal director.
President Barack Obama is examining a review of the surveillance efforts that recommended changes in how the NSA program was conducted. Obama said last week he would decide what to do about it in January.
Last week, U.S. District Judge Richard Leon said the NSA's bulk collection of metadata -- phone records of the time and numbers called without any disclosure of content -- apparently violates privacy rights.
His preliminary ruling favored five plaintiffs challenging the practice, but Leon limited the decision only to their cases.
"I cannot imagine a more 'indiscriminate' and 'arbitrary invasion' than this systematic and high-tech collection and retention of personal data on virtually every citizen for purposes of querying and analyzing it without prior judicial approval," said Leon, an appointee of President George W. Bush. "Surely, such a program infringes on 'that degree of privacy' that the Founders enshrined in the Fourth Amendment."
Leon's ruling said the "plaintiffs in this case have also shown a strong likelihood of success on the merits of a Fourth Amendment claim," adding "as such, they too have adequately demonstrated irreparable injury."
He rejected the government's argument that a 1979 Maryland case provided precedent for the constitutionality of collecting phone metadata, noting that public use of telephones had increased dramatically in three decades.
Leon also noted the government "does not cite a single instance in which analysis of the NSA's bulk metadata collection actually stopped an imminent attack, or otherwise aided the government in achieving any objective that was time-sensitive in nature."
However, he put off enforcing his order barring the government from collecting the information, pending an appeal by the government.
A Justice Department spokesman said in response to Leon's ruling that "we believe the program is constitutional as previous judges have found."
Explosive revelations this year by Snowden triggered new debate about national security and privacy interests in the aftermath of the September 2001 terrorist attacks.
Snowden's disclosures led to more public disclosure about the secretive legal process that sets in motion the government surveillance.
The NSA has admitted it received secret court approval to collect vast amounts of metadata from telecom giant Verizon and leading Internet companies, including Microsoft, Apple, Google, Yahoo and Facebook.
The case before Leon involved approval for surveillance in April by a judge at a Foreign Intelligence Surveillance Court that handles individual requests for electronic surveillance for "foreign intelligence purposes."
Under the Foreign Intelligence Surveillance Act of the 1970s, the secret courts were set up to grant certain types of government requests -- wiretapping, data analysis and other monitoring of possible terrorists and spies operating in the United States.
The Patriot Act that Congress passed after the 9/11 attacks broadened the government's ability to conduct anti-terrorism surveillance in the United States and abroad, eventually including the metadata collection.
In order to collect the information, the government has to demonstrate it is "relevant" to an international terrorism investigation.
However, the 1978 FISA law lays out exactly what the special court must decide: "A judge considering a petition to modify or set aside a nondisclosure order may grant such petition only if the judge finds that there is no reason to believe that disclosure may endanger the national security of the United States, interfere with a criminal, counterterrorism, or counterintelligence investigation, interfere with diplomatic relations, or endanger the life or physical safety of any person."
In defending the program, Gen. Keith Alexander, the NSA's director, told the Senate Judiciary Committee last week that "15 separate judges of the FISA Court have held on 35 occasions that Section 215 (of the Patriot Act) authorizes the collection of telephony metadata in bulk in support of counterterrorism investigations."
Initially, telecommunications companies such as Verizon were the targets of legal action against Patriot Act provisions. Congress later gave retroactive immunity to those private businesses.
The New York ruling makes it more likely that the U.S. Supreme Court will have to tackle the issue of privacy and settle the dispute over the the NSA program.
For years, the courts have relied on a 1979 Supreme Court precedent that found privacy rights didn't extend to personal information people give to third-parties such as the phone companies, which store basic data on calls made. The secret court that oversees the Foreign Intelligence Surveillance Act has relied on that ruling to periodically reauthorize the NSA phone data program.
But technology has come a long way since then; modern cell phones are in constant communication with phone towers and tell a lot more information about phone customers than old land line phones. And at least some justices may be ready to take on the issue again.
Ruling last year in an unrelated case, Supreme Court Justice Sonia Sotomayor wrote that the 1979 standard may be "ill suited to the digital age" because people reveal a lot more information in seemingly mundane tasks.
"It may be necessary to reconsider the premise that an individual has no reasonable expectation of privacy in information voluntarily disclosed to third parties," she wrote.
CNN's Bill Mears and Tom Cohen contributed to this report.