Facebook CEO Mark Zuckerberg makes the keynote address at F8, Facebook's developer conference, in San Jose on May 1. (Marcio Jose Sanchez/AP)

Facebook signed a legally binding pledge Tuesday promising that it would not allow advertisers to exclude people on the basis of race, national origin, religion, sexual orientation and other protected categories from viewing certain ads on the site, a widespread practice that investigators in Washington state called “unlawful discrimination.”

The settlement with Attorney General Bob Ferguson — the result of an approximately two-year probe of the social giant — also guarantees that ads for housing, employment, credit, insurance and "public accommodations” can’t be hidden from users of a particular national origin, veteran or military status, sexual orientation, disability status, religion, or race.

Because it is legally enforceable, the settlement holds Facebook to a higher standard than previous commitments, which until Tuesday had been voluntary. It also expands the types of ads that will receive more enforcement from Facebook to include insurance and “public accommodations” — two categories Facebook had never explicitly said were covered under its anti-discrimination efforts.

The state’s probe stemmed from reports in ProPublica, beginning in 2016, that found advertisers, using Facebook’s micro-targeting tools, could conceal housing ads from African American users and other minorities. Investigators in the attorney general’s office said Tuesday that they tested the system by creating “20 fake ads" on Facebook as part of their investigation in November and December 2017, touching everything from nightclubs to employment opportunities, that “excluded one or more ethnic minorities.”

After the ProPublica investigation, Facebook said it would no longer let advertisers target ads for housing, credit offers and employment by “ethnic affinities,” a category that the social network had created to enable businesses to reach minority groups.

Even after Facebook’s first pledge, which was voluntary, reports revealed that advertisers who posted housing ads were still able to exclude people on the basis of race, calling into question Facebook’s promise of stepped-up enforcement. Facebook’s ad system also automatically approved housing excluding other types of people, such as mothers of high school kids, Jews and Spanish speakers.

Tuesday’s agreement with Washington makes the commitment legally binding. As part of its settlement Facebook did not have to admit that it violated state anti-discrimination laws as part of the proceeding, but it could face additional penalties if Washington finds other future instances of discrimination.

The order technically covers only Facebook's business within the state, but Furguson said that the company would adhere to the policy nationally.

“If a restaurant owner put a sign out front that said, ‘whites only,’ we all know the reaction. Well, my team posted an ad on Facebook that said ‘whites only,’ and it got accepted,” Furguson said in an interview.

In response, Will Castleberry, Facebook's vice president for state and local policy, said in a statement that the company had "worked closely with them to address the issues they've raised," adding: "Discriminatory advertising has no place on our platform, and we'll continue to improve our ad products so they're relevant, effective, and safe for everyone.”

Like its peers in Silicon Valley, Facebook has struggled to find its footing on issues of race and discrimination. Even within its own ranks, white men make up much of its workforce: Black employees, in contrast, hold about 1 percent of the technical roles at Facebook, while Hispanic employees hold 3 percent, according to data the company released in July. Both numbers are relatively unchanged from the previous year.

In the nation’s capital, federal lawmakers also have urged Facebook to diversify its workforce. Members of the Congressional Black Caucus pushed the tech giant to add people of color to its board of directors, an addition Facebook made earlier this year with the selection of then-American Express CEO Kenneth Chenault.

Peter Romer-Friedman, an attorney involved in a class-action suit accusing Facebook of enabling discrimination in job ads against older Americans, said Facebook’s agreement on Tuesday did not protect older adults as well as discrimination on the basis of gender.

“Right now as we speak, Facebook is literally sending job ads that exclude people on the basis of their age,” he said. “It’s laudable that the AG has gotten Facebook to agree to some basic first steps, but this agreement really doesn’t do much more than what FB has agreed to do voluntarily.”