A federal judge ruled Wednesday it is unconstitutional for the Trump administration to require states to cooperate with immigration enforcement in order to get some Federal Emergency Management Agency grants — a legal setback in the administration’s push to revoke funding to “sanctuary” cities and states.

U.S. District Judge William Smith of Rhode Island ruled in favor of 20 mostly Democratic states that had sued FEMA, accusing the administration of “holding critical emergency preparedness and response funding hostage” unless they assist immigration agents.

The decision is likely to be appealed.