Facebook Inc. struck customized data-sharing deals that gave select companies special access to user records well after the point in 2015 that the social network has said it walled off that information, according to court documents, company officials and people familiar with the matter.

Some of those and other agreements, collectively known internally as “whitelists,” also allowed certain companies to access additional information about a user’s Facebook friends, the people familiar with the matter said. That included information...