By Jonathan Stempel

NEW YORK (Reuters) - A federal judge ruled that a National Security Agency program that collects records of millions of Americans' phone calls is lawful, calling it a "counter-punch" to terrorism that does not violate Americans' privacy rights.

Friday's decision by U.S. District Judge William Pauley in Manhattan diverged from a ruling by another judge this month that questioned the program's constitutionality, raising the prospect that the Supreme Court will need to resolve the issue.

In a 54-page decision, Pauley dismissed an American Civil Liberties Union lawsuit contending that the NSA collection of "bulk telephony metadata" violated the bar against warrantless searches under the Fourth Amendment of the U.S. Constitution.

The judge also referred often to the September 11, 2001 attacks, in which nearly 3,000 people died, and said broad counter-terrorism programs such as the NSA's could help avoid a "horrific" repeat of those events.

"This blunt tool only works because it collects everything," Pauley wrote. "Technology allowed al Qaeda to operate decentralized and plot international terrorist attacks remotely. The bulk telephony metadata collection program represents the government's counter-punch."

The program's existence was first disclosed by former NSA contractor Edward Snowden, who is now in Russia under temporary asylum. His leaks have sparked a debate over how much leeway to give the government in protecting Americans from terrorism.

ACLU PLANS APPEAL

Pauley ruled 11 days after U.S. District Judge Richard Leon in Washington, D.C. said the "almost Orwellian" NSA program amounted to an "indiscriminate and arbitrary invasion" that was likely unconstitutional.

Leon also ordered the government to stop collecting call data on the two plaintiffs in that case, but suspended that portion of his decision so the government could appeal.

The ACLU has argued before Pauley that the NSA program was an unwarranted "dramatic expansion" of the government's investigative powers over Americans' day-to-day lives.

Story continues

Jameel Jaffer, deputy legal director of the ACLU, on Friday said the group was "extremely disappointed" with Pauley's decision, saying it does away with "core constitutional protections. He said the ACLU will appeal to the 2nd U.S. Circuit Court of Appeals in New York.

White House spokesman Josh Earnest declined to comment. U.S. Department of Justice spokesman Peter Carr said the department is pleased with the decision.

Stephen Vladeck, an American University law professor who specializes in national security, said if federal appeals courts in New York or Washington, D.C. ultimately accept Leon's analysis, "then it seems likely, if not certain, that this case will get to the (Supreme Court) by the end of next year."

President Barack Obama has defended the surveillance program but has indicated a willingness to consider constraints, including whether to give control of metadata to phone companies or other third parties. Intelligence officials have said this could prove costly and slow investigations.

On December 18, a White House-appointed panel proposed curbs on some NSA surveillance operations.

It said that because intelligence agencies could not point to specific cases where telephony metadata collection led to a major counter-terrorism success, the intrusiveness of such intelligence gathering might outweigh the public benefit.

Obama is expected next month to set forth his own proposals for possible surveillance reforms.

RUBBER STAMP, OR VITAL WEAPON?

In rejecting the ACLU motion for a preliminary injunction to block the NSA program, Pauley said the public interest tilted "firmly" toward the government, for which combating terrorism "is an urgent objective of the highest order."

While acknowledging that the program "vacuums up information about virtually every telephone call to, from, or within the United States," he said its constitutionality "is ultimately a question of reasonableness."

Pauley added that he found no evidence that the government had used bulk telephony metadata for any reason other than to investigate and disrupt terrorist attacks.

The program also faces a legal challenge by the Electronic Frontier Foundation, a data privacy group. In a statement, the group said it was "obviously disappointed" with Pauley's decision, but that it would continue pursuing its own cases.

Larry Klayman, a conservative legal activist who brought the case before Judge Leon, called Pauley's ruling "an outrageous decision that ignores the legitimate fears of the American people and in effect rubber stamps a police state."

Pauley was appointed to the bench by President Bill Clinton. Leon was appointed by President George W. Bush.

Both cases interpreted a 1979 Supreme Court decision, Smith v. Maryland, that said people have no "legitimate expectation of privacy" regarding phone numbers they dial because they knowingly give that information to phone companies.

While Leon said Smith's relevance had been "eclipsed" by technological advances and the advent of cell phones, Pauley said this did not undermine the finding that people have "no subjective expectation of privacy in telephony metadata."

Rep. Peter King, a New York Republican and chairman of the House Homeland Security Subcommittee on Counterintelligence & Terrorism, in a statement said Pauley's decision "preserves a vital weapon for the United States in our war against international terrorism."

The case is American Civil Liberties Union et al v. Clapper et al, U.S. District Court, Southern District of New York, No. 13-03994.

(Reporting by Jonathan Stempel in New York; Additional reporting by Mark Hosenball, Ros Krasny and Nate Raymond; Editing by Leslie Gevirtz and Dan Grebler)