SEATTLE - Facebook and Washington state have reached a legally binding agreement that requires the tech giant to stop enabling advertisers to unlawfully discriminate in who sees their ads.

Facebook says it was already doing so. Under pressure from civil rights activists, it announced in April it removed thousands of categories from its "exclusion targeting" tools, which allow companies to control who sees their ads, including for jobs and housing. The removed categories included attributes such as race, ethnicity, sexual orientation and religion.

Washington Attorney General Bob Ferguson said his office had been investigating Facebook for 20 months, since the investigative news website ProPublica revealed that Facebook's ad system allowed advertisers to exclude people by race, gender and other protected categories, in violation of federal law.

The agreement filed in state court in Seattle on Tuesday requires Facebook to remove the exclusionary categories not just for ads pertaining to jobs, housing and credit, but for any business open to the public.