Uncovering and explaining how our digital world is changing — and changing us.

This story is part of a group of stories called

Facebook must face a class action lawsuit accusing it of violating its users’ privacy by scanning the content of messages they send to other users for advertising purposes, a U.S. judge has ruled.

U.S. District Judge Phyllis Hamilton in Oakland, California, on Tuesday dismissed some state-law claims against the social media company but largely denied Facebook’s bid to dismiss the lawsuit.

Facebook had argued that the alleged scanning of its users’ messages was covered by an exception under the federal Electronic Communications Privacy Act for interceptions by service providers occurring in the ordinary course of business.

But Hamilton said Facebook had “not offered a sufficient explanation of how the challenged practice falls within the ordinary course of its business.”

Neither Facebook nor a lawyer for the plaintiffs responded to a request for comment Wednesday.

The lawsuit, filed in 2013, alleged that Facebook scanned the content of private messages sent between users for links to websites and would then count any links in a tally of “likes” of the pages.

Those “likes” were then used to compile user profiles, which were then used for delivering targeted advertising to its users, the lawsuit said.

The complaint alleged that the scanning of the private messages violated the federal and California state law.

According to Tuesday’s ruling, Facebook ceased the practice at issue in October 2012. But the company said it still does some analysis of messages to protect against viruses and spam, the ruling said.

The lawsuit was filed by Facebook user Matthew Campbell and seeks class action status on behalf of U.S. users who sent or received private messages that included website addresses in their content.

The case is Campbell v. Facebook Inc, U.S. District Court, Northern District of California, No. 13-5996.

(Reporting by Nate Raymond in New York; Editing by Chizu Nomiyama)