Last year, a longtime engineer at Facebook Inc. gathered data that revealed a controversial finding: Code written by women was rejected much more frequently than code written by their male colleagues, according to people familiar with the matter and screenshots of internal discussions viewed by The Wall Street Journal.

For many female engineers at Facebook, the finding confirmed long-held suspicions that their coding faced more scrutiny than men’s.

The results touched off a debate within Facebook over alleged gender bias among some of its most-valued employees: the engineers who build the features used by nearly two billion people every month. Chief Executive Mark Zuckerberg was asked about the findings during a weekly town hall meeting.

The outcry prompted senior Facebook officials to conduct their own review of the engineer’s study. In an internal post published a month later, Jay Parikh, Facebook’s head of infrastructure, attributed any gap in rejection rates to an engineer’s rank, not gender. Many employees interpreted this new analysis as a sign that female engineers weren’t rising at the same rate as men who joined the company around the same time.

In a statement to the Journal, a Facebook spokeswoman described the initial analysis as “incomplete and inaccurate—performed by a former Facebook engineer with an incomplete data set.” The spokeswoman confirmed Mr. Parikh’s analysis, which was based on confidential data unavailable to most employees. The spokeswoman added that there aren’t enough women at senior engineering levels at Facebook and across the technology industry.