Google's Gmail automatic keyword scanning might violate laws in the United States against wiretapping, a federal judge ruled on Thursday.

U.S. District Judge Lucy Koh said that by automatically scanning Gmail users' emails to provide targeted ads and filter spam, Google may be in breach of Federal and California state wiretapping laws, which prohibit the unauthorized interception of communications. The decision, embedded below, came in a proposed class-action suit that several users have brought forth claiming Google wiretaps Gmail.

See also: How to Lock Down Facebook Privacy

In June, Google filed a motion asking the judge to dismiss the case, arguing that the federal Wiretap Act authorizes email providers to intercept messages if it allows them to better deliver the messages or is incidental to how the service works.

Judge Koh disagreed.

"Accordingly, the statutory scheme suggests that Congress did not intend to allow electronic communication service providers unlimited leeway to engage in any interception that would benefit their business models, as Google contends," Judge Koh wrote in the decision. "In fact, this statutory provision would be superfluous if the ordinary course of business exception were as broad as Google suggests."

The search giant also argued that its keyword scanning is authorized by the users — and even non-Gmail users who send emails to Gmail recipients — when they agree to the terms of service. But the judge wasn't swayed by this argument, either.

"The court finds that it cannot conclude that any party — Gmail users or non-Gmail users — has consented to Google’s reading of e-mail for the purposes of creating user profiles or providing targeted advertising," Koh said in the ruling.

In response to the decision, Google defended its technology, arguing it helps provide a better service.

"We're disappointed in this decision and are considering our options. Automated scanning lets us provide Gmail users with security and spam protection, as well as great features like Priority Inbox," Google said in an email statement.

There is no date set for the trial, and as Wired reports, the judge will likely grant an appeal to Google before holding a trial.

Google Gmail Order Sept. 26 2013

Image: Adam Berry/Getty Images