The Department of Housing and Urban Development is accusing Facebook of violating the Fair Housing Act.

The agency filed a formal complaint against the social media company on Friday, alleging that it allows landlords and home sellers to use targeted Facebook (FB) ads to discriminate against potential buyers or tenants on the basis of race, sex, religion, disability and other characteristics.

"When Facebook uses the vast amount of personal data it collects to help advertisers to discriminate, it's the same as slamming the door in someone's face," Anna María Farías, assistant secretary for fair housing and equal opportunity, said in a statement.

Facebook responded to the allegation with a statement insisting that "there is no place for discrimination on Facebook; it's strictly prohibited in our policies. Over the past year we've strengthened our systems to further protect against misuse... and we'll continue working directly with HUD to address their concerns."

The federal Fair Housing Act prohibits home rental and sale advertisements from discriminating "based on race, color, religion, sex, handicap, familial status, or national origin."

In its complaint, the federal housing agency outlined several ways landlords or sellers can use Facebook ads to do just that. They could, for example, decide to show the ads to only men, or ensure that their ads don't appear in the feeds of anyone with "accessibility" listed as an interest.

The National Fair Housing Alliance made the same argument in a federal lawsuit against the social media company. The case, filed in March in New York City, claims that Facebook's advertising tools continue to allow marketers to exclude women and families with children from seeing certain housing ads.

Diane L. Houk, one of the attorneys who filed that suit, called Friday's complaint "a very important step by HUD to enforce the Fair Housing Act."

HUD and the US Attorney for the Southern District of New York also filed documents bolstering the suit brought by the housing advocates. In a statement of interest filed with the court, they rejected Facebook's argument that it is protected from the federal housing law by the Communications Decency Act, which limits the liability of website operators.

The government argued that Facebook should in this case be classified as an internet content provider and is therefore subject to the Fair Housing Act.

Facebook said it "will respond in court" to the statement of interest.

Some of the details outlined in the HUD complaint, such as accusations of exclusion based on religion or an interest in "deaf culture" do not appear in the lawsuit filed by the National Fair Housing Alliance.

Houk said it is "very troubling to see that these categories are still available," especially "given the amount of public statements and coverage ... over the last two years."

According to the HUD complaint, the alleged violations occurred as recently as last month. But Facebook has faced such accusations since 2016, when ProPublica reported posting an ad for a housing event that it requested not be shown to anyone with what Facebook's ad tool calls an "ethnic affinity" of African-American, Asian-American or Hispanic.

"Our policies prohibit using our targeting options to discriminate, and they require compliance with the law," a Facebook spokesperson said in a statement at the time. "We take prompt enforcement action when we determine that ads violate our policies."

ProPublica said last year that it was able to buy dozens of home rental advertisements targeted toward audiences that specifically excluded "African Americans, mothers of high school kids, people interested in wheelchair ramps, Jews, expats from Argentina and Spanish speakers."

— CNN's Seth Fiegerman contributed to this report.