On Facebook’s ad-buying website, however, advertisers can choose to include or exclude certain demographic “affinities” from ads in the United States. For instance, they can exclude African-American, Asian-American and four “types” of Hispanic — bilingual, English-dominant, Spanish-dominant or all of the above. Facebook lists the number of people who match those affinities within its ads tool.

For example, if an advertiser wants to reach Americans ages 18 and up on Facebook, the company indicates that there are 26 million people with the “ethnic affinity” of African-American. The company confirmed that because the assignment is based on activity, a white person could be targeted as African-American and vice versa.

Facebook users can visit their Ad Preferences and see what, if any, ethnic affinity is assigned to them under their “lifestyle and culture” interests, and remove it if they want, the company said. A reporter for The New York Times who is Indian-American did not have “Asian-American” listed under her interests in that section. A colleague, who is Hispanic and speaks primarily English, had “Ethnic affinity: African-American (U.S.)” listed under descriptions like “away from family” and “books.”

ProPublica, for its article last month, bought an ad targeting Facebook users who were house hunting, and excluded people with an “affinity” for African-American, Asian-American or Hispanic people. The publication showed the ad to a civil rights lawyer, who called it a “blatant” violation of the Fair Housing Act.

On Friday, Facebook declined to disclose the number of housing, credit and employment ads placed using ethnic affinity targeting. The company brought in roughly $18 billion in revenue last year, almost all of it from advertising.

In her blog post, Ms. Egan wrote that this type of targeting “gives brands a way to reach multicultural audiences with more relevant advertising.” In addition to tools that will disable ethnic affinity marketing for housing, employment or credit ads, Facebook will “require advertisers to affirm that they will not engage in discriminatory advertising” on the site and offer them information so they “understand their obligations with respect to housing, employment and credit.”