A federal judge on Monday ordered the Trump administration to vacate a policy that allowed officials to deny green cards to immigrants who might need public assistance, such as food stamps and housing vouchers, saying it exceeded the authority of the executive branch.

In a 14-page ruling, Judge Gary Feinerman of the U.S. District Court for the Northern District of Illinois cited “numerous unexplained flaws” that made the rule “arbitrary and capricious,” including an interpretation of self-sufficiency that had no basis in the statute it purportedly interpreted, and the failure to consider the “predictable collateral consequences” of its implementation.

The policy, known as the public charge rule, was announced in September 2018 and effectively created a wealth test for immigrants seeking permanent residency by rendering inadmissible applicants deemed likely to use a broad range of safety-net programs. In addition to reaching beyond the power of the executive branch, Feinerman wrote, the rule ran afoul of the Administrative Procedure Act, which governs how regulations are developed and rolled out.

The Trump administration is expected to appeal the decision, and the case could end up before the Supreme Court. Meanwhile, U.S. Citizenship and Immigration Services, whose officers adjudicate green cards, cannot apply the new standard in reviewing applications. The agency’s spokesman, Dan Hetlage, said the agency would fully comply with the decision and issue additional forthcoming guidance after reviewing it.

Advocates who had feared that the policy would harm tens of thousands of poor people, particularly those affected by widespread job loss because of the coronavirus pandemic, hailed the court decision.

The fear and confusion the policy created “led to decreased participation in public programs and placed a heavy burden on local governments and community-based organizations to replace them,” said Militza M. Pagán, a staff lawyer at the Shriver Center on Poverty Law who represented the plaintiffs.

Though the idea of public charges is a long-standing principle of U.S. immigration law, it historically was applied to those deemed likely to primarily depend on the federal government for survival, such as through public cash assistance or institutionalized long-term care.

“Congress never intended that you be denied a green card if you ever touch a food stamp, which is what the Trump administration has tried to do by dramatically expanding the meaning of public charge,” said Doug Rand, a founder of Boundless Immigration, a technology company in Seattle that helps immigrants obtain green cards and citizenship.