Internal emails show Facebook Inc. FB 2.12% considered charging companies for continued access to user data several years ago, a step that would have marked a dramatic shift away from the social-media giant’s policy of not selling that information, according to an unredacted court document viewed by The Wall Street Journal.

The emails in the document also indicate that Facebook employees discussed pushing some advertisers to spend more in return for increased access to user information.

Taken together, the internal emails show the company discussing how to monetize its user data in ways that are employed by some other tech firms but that Facebook has said it doesn’t do.

At a congressional hearing in April, Facebook Chief Executive Mark Zuckerberg said, “I can’t be clearer on this topic: We don’t sell data.”

Facebook CEO Mark Zuckerberg didn't turn up to a U.K. parliamentary committee inquiry into fake news and disinformation, irking lawmakers. A Facebook representative was asked to explain the social-media company's policy on data harvesting and privacy.

The emails—most from about 2012 to 2014—are far from conclusive, lacking context and in some cases truncated. But they provide a window into mostly sealed court filings—which a British lawmaker has pledged to make public next week—from a lawsuit against Facebook filed by a company called Six4Three LLC.

The emails also illustrate how Facebook has long grappled with how to maximize the value of the vast amounts of data it collects without abusing the privacy of users.

Six4Three, the developer of a now-defunct app, sued Facebook in 2015, alleging that its data policies were anticompetitive and favored certain companies over others. The majority of the documents filed in the case have been placed under seal at Facebook’s urging and on orders from a California judge.

The Wall Street Journal viewed three pages of unredacted material from one 18-page document that showed portions of some internal emails. In other court filings, Facebook said these excerpts were subsequently redacted because they contained “sensitive discussion of Facebook’s internal strategic analysis of third-party applications, the release of which could damage Facebook’s relationships” with those apps.

On Tuesday, the British lawmaker, Damian Collins, chairman of the House of Commons Digital, Media, Culture and Sport Committee, said he planned to release documents he had obtained from the Six4Three lawsuit in roughly a week, once he had redacted all personal information. Mr. Collins has been a staunch advocate of data privacy and highly critical of Facebook.

A Facebook spokeswoman confirmed the discussions about charging for data and said the company ultimately decided against it.

Konstantinos Papamiltiadis, Facebook’s director of developer platforms and programs, said, “The documents Six4Three gathered for this baseless case are only part of the story and are presented in a way that is very misleading without additional context.”

The company declined to provide the full text of the emails.

A representative for Six4Three, which made an app that allowed users to search for photos of people in their bathing suits, hasn’t responded to requests for comment.

Damian Collins, chairman of the U.K. House of Commons’ digital culture and sport committee, earlier this year asked Facebook chief Mark Zuckerberg to answer for a ‘catastrophic failure of process’ concerning U.K. firm Cambridge Analytica. Photo: Simon Dawson/Bloomberg News

Consumers and regulators on both sides of the Atlantic are trying to understand how Facebook uses the data of its 2.27 billion monthly users. Facebook has been under intense scrutiny in the past year for its practices of sharing user data, particularly after the company revealed earlier this year that analytics firm Cambridge Analytica improperly obtained personal data of millions of users.

The Facebook emails referenced in the 18-page court document that was viewed by the Journal date back to the fall of 2012. At the time, Facebook had just emerged from a rocky public offering and was struggling to generate revenue from its mobile product while operating under a data-sharing policy established years earlier under Mr. Zuckerberg.

The policy allowed tens of thousands of outside app developers to access private information about Facebook users by plugging into the company’s developer platform. But developers were gaining access to that invaluable trove of data without giving Facebook anything in return.

As Facebook considered adjusting its strategy, employees discussed ways to get more revenue and data from developers, the Six4Three document shows.

An unidentified Facebook employee mentioned shutting down data access “in one-go to all apps that don’t spend… at least $250k a year to maintain access to the data,” according to one email referenced in the document. The full content of the email wasn’t included.

“We were trying to figure out how to build a sustainable business,” a Facebook spokeswoman said. “We had a lot of internal conversations about how we could do this.”

Some of the deals discussed in the document appear to involve Facebook potentially receiving more ad dollars in return for access to user data. Those deals would have been at odds with Facebook’s stated business philosophies, and would have gone beyond the preferential access to private data given to some companies, which the Journal previously reported.

The backdrop for some of the discussions was Facebook’s pending move to restrict developers from seeing information on users’ friends, such as name, birth date, photos and page likes. The company announced the move in 2014, and it went into effect the next year.

In 2013, as the company negotiated a special agreement with Amazon.com Inc., a Facebook employee noted that Amazon would soon be getting less access to data. As a result, another employee replied, “we’ll need to either have a disappointing conversation with Amazon or a strategic conversation in the context of the broader deal discussions,” according to the court document.

It is not clear what those deal discussions entailed. An Amazon spokesman said the company accesses Facebook data to “enable Facebook experiences for our products.” He added, “We use information only in accordance with our privacy policy.”

When the Royal Bank of Canada during that same year expressed concern about its access to data, an unidentified Facebook employee asked internally whether the bank had an agreement requiring it to spend a certain amount on advertising each year. Another employee responded, “I believe it will be one of the biggest NEKO campaigns ever run in Canada,” referencing an acronym used to describe mobile app-install ads.

A spokesman for RBC said the bank “never had a minimum marketing spend or target agreement with Facebook.”

In one email exchange cited by the Six4Three court document, Facebook employees allegedly offered to extend the data access of Match Group Inc.’s Tinder dating app to the data that would soon be shut off in return for the use of its “Moments” trademark, which Facebook wanted to use for a future photo-sharing app.

Tinder and Facebook years ago resolved a trademark dispute over “Moments,” and “Tinder never received special treatment, data or access related to this dispute or its resolution,” a Tinder spokeswoman said. A Facebook spokeswoman said the companies never exchanged the trademark for access to data.

Write to Deepa Seetharaman at Deepa.Seetharaman@wsj.com and Kirsten Grind at kirsten.grind@wsj.com