Just this month, Facebook noted, it had removed the advertisers’ ability to target housing, credit and jobs ads by age, gender, ZIP code and other characteristics in ways that could be considered discriminatory. Federal law explicitly prohibits advertising, including online, from discriminating in those categories. The social network also recently settled a lawsuit filed by the National Fair Housing Alliance, the American Civil Liberties Union and other civil rights organizations over its advertising practices.

A Twitter spokesman said the company “doesn’t allow discriminatory advertising on our platform.” A Google spokesman said, “We’ve had policies in place for many years that prohibit targeting ads on the basis of sensitive categories like race, ethnicity, religious beliefs, disability status, negative financial standing, etc.”

The housing agency’s suit underscores how effective Facebook’s ad-targeting tools are, and how they could perpetuate discriminatory behavior if used by those who want to exclude people based on race, religion, gender or other criteria.

Facebook collects a vast amount of information about its users, and uses its technology to draw additional inferences about them. In its pitch to advertisers, the complaint says, the company notes that “most online advertising tools have limited targeting options” including “age, gender, interests and potentially a few others.” But, the pitch continues, “Facebook is different. People on Facebook share their true identities, interests, life events and more,” according to the complaint.

The complaint also accuses Facebook of going further than advertisers may ask in targeting users. The company’s “ad delivery system will not show the ad to a diverse audience if the system considers users with particular characteristics most likely to engage with the ad,” the complaint says, even if an advertiser wants the ad to be seen broadly by users.

“If the advertiser tries to avoid this problem by specifically targeting an unrepresented group, the ad delivery system will still not deliver the ad to those users, and it may not deliver the ad at all,” the complaint says.

The complaint does not name any advertisers who used Facebook’s targeted ad tools.

HUD’s lawsuit follows nearly three years of scrutiny of Facebook’s ad-targeting practices that started with a 2016 investigation by ProPublica, whose reporters showed that the company made it simple for marketers to exclude specific ethnic groups for advertising purposes.