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.