Facebook is facing a class-action lawsuit in the US which alleges the company mines data from private messages without users' knowledge or consent, and shares the information with advertisers.

The lawsuit by two US users accuses Facebook of violating the Electronic Communications Privacy Act and California privacy laws by allegedly scanning private messages for links to third-party websites, which it then shares with "advertisers, marketers and other data aggregators".

The complaint was filed by Matthew Campbell of Arkansas and Michael Hurley of Oregon on December 30 in the District Court for Northern California on behalf of all Facebook members in the US that have used the site to send or receive private messages that include a URL link.

The lawsuit accused Facebook of using the information for "data mining and user profiling", and said that Facebook earned $2.7bn from targeted advertising sales in 2011.

"Representing to users that the content of Facebook messages is 'private' creates an especially profitable opportunity for Facebook, because users who believe they are communicating on a service free from surveillance are likely to reveal facts about themselves that they would not reveal had they known the content was being monitored," the lawsuit said.

Facebook has denied the plaintiffs' claims, saying in a statement on Friday: "The allegations in this lawsuit have no merit and we will defend ourselves vigorously".

The case is similar to another lawsuit accusing Google of violating user privacy by scanning the contents of Gmail messages.

Facebook has faced a slew of complaints and court actions on privacy-related issues. Last year, it settled a class action lawsuit over its usage of user names and images in so-called "sponsored stories".