U.S. District Judge Jeannette Vargas of the Southern District of New York ruled that the State Department’s policy was “patently unlawful” and exceeded Secretary of State Marco Rubio’s statutory authority.

The State Department announced on January 14 that it would temporarily suspend the issuance of immigrant visas to nationals of 75 countries. The measure took effect on January 21 and covered Uzbekistan, Kazakhstan, Kyrgyzstan, Russia, Iran, Pakistan, Brazil and dozens of other countries.

The Trump administration said the policy was aimed at preventing immigrants from becoming dependent on public assistance and other government-funded social programs after arriving in the United States. Officials classified applicants from the affected countries as being at high risk of becoming a “public charge.”

Judge Vargas said, however, that immigration authorities must assess applicants on an individual basis rather than deny visas categorically based on nationality. According to the ruling, State Department guidance required consular officers to refuse immigrant visas even to applicants who had submitted additional evidence showing they were unlikely to become a financial burden on the United States. The judge found that approach inconsistent with federal immigration law.

The ruling cancels visa denials issued solely on the basis of the suspended policy. As a result, thousands of previously denied applications could be reconsidered. The case was brought by immigrant rights groups, affected visa applicants and U.S. citizens sponsoring family members.

The decision is another legal setback for the Trump administration’s immigration policies. In June, U.S. District Judge Leo Sorokin in Boston ruled that a $100,000 fee imposed on new H-1B visas for highly skilled foreign workers was unlawful, finding that the administration had exceeded its authority by imposing what amounted to a tax without congressional authorization.