WASHINGTON -- For the first time, a federal judge has struck down the National Security Agency’s once-secret policy of collecting the dialing records of all phone calls in the country, ruling that the mass data collection involving innocent Americans appears to violate the Constitution’s ban on unreasonable searches.

U.S. District Judge Richard J. Leon, who was appointed to the federal district court in Washington by President George W. Bush, immediately stayed Monday’s ruling to give the government time to appeal. As a result, his ruling will have no immediate impact in stopping the massive data-collection effort.

Still, the ruling marked the government’s first full-on courtroom defeat in the controversy that erupted after former NSA analyst Edward Snowden revealed the scope of the agency’s program.

The ruling broke new legal ground by deciding that today’s computerized gathering of all dialing records represents a new threat to privacy that was not fully recognized in the past.

PHOTOS: The year in national news

In 1979, the Supreme Court said that phone records -- unlike the content of phone calls -- were not protected under the 4th Amendment. The justices allowed police detectives to use a much more primitive technology -- a pen register -- to record the numbers a suspect dialed without a search warrant.

Today, by contrast, the NSA's computers can gather, store and sift untold millions of calls, and that changes the constitutional balance, Judge Leon wrote.

“The almost Orwellian technology that enables the government to store and analyze the phone meta-data of every telephone user in the United States is unlike anything that could have been conceived in 1979,” he wrote.

He also questioned whether the phone records were useful in fighting terrorism. “The government does not cite a single instance in which analysis of the NSA’s bulk data collection actually stopped an imminent attack,” Leon said.

Because technology has changed so much, and the scope of the government’s surveillance operations is so much greater than what was involved in the 1979 case, that ruling no longer can be considered a binding precedent, the judge said.

Follow Politics Now on Twitter and Facebook

Twitter: @davidsavage

david.savage@latimes.com