The Trump administration charged Facebook on Thursday with "discrimination" in its advertising practices for housing.

In a civil compliant, the Department of Housing and Urban Development is seeking damages for any person who was harmed by Facebook's targeted advertising policies, which until recently allowed employers and landlords to limit their audiences on the basis of race, ethnicity or gender. Facebook settled a lawsuit with the ACLU over the practice last week and overhauled its systems as a result.

A senior HUD official told CNBC that based on Facebook's user base and the proliferation of housing ads, the agency expects the number of users affected by the discriminatory practices could number in the millions.

"[Facebook] holds out its advertising platform as a powerful resource for advertisers in many industries, including housing and housing-related services," the complaint says. But, "because of the way [Facebook] designed its advertising platform, ads for housing and housing-related services are shown to large audiences that are severely biased."

HUD is asking for unspecified monetary damages and "the maximum civil penalty" against Facebook for each violation of housing laws. It said the charge will be heard by a federal administrative law judge unless any party requests the case to be heard in federal district court.

The complaint details tools through which an advertiser can exclude a person who doesn't speak a certain language, or a person of a specific gender from being shown the paid post. An advertiser can also exclude residents of a certain zip code, or draw a red line around geographic areas they want to avoid.

"Facebook is discriminating against people based upon who they are and where they live," HUD Secretary Ben Carson added in a statement. "Using a computer to limit a person's housing choices can be just as discriminatory as slamming a door in someone's face."

The agency has also reached out to Twitter and Google regarding their ad targeting practices, a HUD official told CNBC. The Washington Post first reported the expanded inquiry.

Spokespeople for both Twitter and Google said the companies' policies prohibit ad targeting based on protected characteristics such as race, ethnicity, and religion as well as disability status and negative financial standing.

A Facebook spokesperson said the company is surprised by HUD's action.

"While we were eager to find a solution, HUD insisted on access to sensitive information — like user data — without adequate safeguards," the spokesperson said. "We're disappointed by today's developments, but we'll continue working with civil rights experts on these issues."

Facebook also pointed to a blog post published last week, in which the company said the advertising overhaul marked an important step for the platform and thanked the civil rights organizations that helped improve the ad tools.

"There is a long history of discrimination in the areas of housing, employment and credit, and this harmful behavior should not happen through Facebook ads," COO Sheryl Sandberg said at the time. "Our policies already prohibit advertisers from using our tools to discriminate. We've removed thousands of categories from targeting related to protected classes such as race, ethnicity, sexual orientation and religion. But we can do better."

Facebook has drawn harsh criticism for its ad-based business model in recent months. The service allows advertisers to customize their audience based on specific and often user-supplied criteria for demographics and stated interests. That's how advertisers were able to target posts to "Jew-haters," for example.

The self-service portal is also how Russian agents were able to purchase tens of thousands of dollars worth of inflammatory posts around U.S. elections.

Here's the full complaint from HUD: