San Francisco and Santa Clara County in California filed a lawsuit Tuesday to block the Trump administration from implementing a new rule that would deny permanent residency to legal immigrants if they are judged likely to use government benefit programs.

President Trump issued the regulation, called the public charge rule, on Monday. Starting in October, the federal government plans to base decisions about permanent legal status on a wealth test: Poor immigrants would be denied if they are deemed likely to use programs like food stamps or subsidized housing, while wealthier immigrants designated as less likely to require public assistance would be approved.

In the lawsuit, filed in United States District Court in San Francisco, the counties say the rule would have a “chilling effect.” It would push many away from needed federal health care programs that also guard communities against disease, like the Zika virus. Local governments would have to provide similar services and pick up the costs, the lawsuit says.

“This illegal rule is yet another attempt to vilify immigrants,” Dennis Herrera, San Francisco’s city attorney, said in a statement Tuesday. “It makes it easier to unfairly target hard-working, lawful immigrants while sowing fear and confusion in our communities.