A federal judge has temporarily stopped most of Texas' controversial anti-sanctuary city law from being enforced, just two days before it was scheduled to take effect.

Orlando Garcia of the United States District Court for the Western District of Texas hasn't completely shut down the law. But in a lengthy ruling released Wednesday night Garcia determined the cities and counties within the state who filed suit to stop the law have a good chance of winning on some of the claims. A temporary injunction stops much of the law from being implemented as the lawsuit moves forward.

Senate Bill 4, passed in May by an extremely contentious state legislature, pitted the state's Republican leadership against the Democratic rule of several major cities in the state. The law was directed at "sanctuary cities"—cities where officials generally do not ask the citizenship status of people within their borders.

The law requires local police to assist Immigration and Customs Enforcement (ICE) in deportation efforts and comply with immigration "detainer" orders. These are requests that come from ICE or the Department of Homeland Security (DHS) asking a local law enforcement agency to detain people in the country illegally until the feds can pick them up for deportation.

Detainer orders are simply requests. No local law enforcement agency is under any legal obligation to comply. Cities, counties, and states have developed various guidelines for compliance. Many require DHS to get an arrest warrant. Many so-called sanctuary cities cooperate with detainer orders for immigrants with violent criminal records.

SB 4 overruled the policies cities put in place. The law also threatened law enforcement leaders with criminal and civil penalties and their removal from office for refusing to help the feds. The law even banned local government officials from publicly endorsing policies that ran counter to enforcement of immigration law.

Cities and counties are claiming SB 4 violates a host of constitutional rights—the First Amendment, the Fourth Amendment, the Fourteenth Amendment, the Ninth Amendment, and the Tenth Amendment, not to mention the Supremacy Clause and Texas' own constitution.

There is an attitude among some who want more enforcement of immigration laws that a person in the country illegally has no rights and can be treated as a convicted criminal. It isn't true as a legal matter. A person cannot be held by local police for an indeterminate amount of time simply on suspicion that they're not in the country legally.

In July, the Massachusetts' Supreme Court ruled police in the state legally did not have the authority to detain people solely at the request of immigration officials. Given that local police are not federal immigration officials, it's a Fourth Amendment violation to hold them in absence of any other criminal conduct.

Garcia's ruling comes to a similar conclusion about detainer orders in Texas:

SB 4 prohibits local officials from undertaking any particularized assessment of suspected criminality. Rather, it mandates that they effect a seizure simply because it was requested by ICE, who issues that request based upon suspicion that the subject of the request is removable, not based on suspicion of a crime. … Under SB 4, this assessment of immigration status must be made by local officials, who are generally not trained in the complex field of immigration status determinations, and who, if they are mistaken, face the risks of financial penalties, removal from office, and criminal prosecution by Defendants on the one hand, or wrongfully detaining a citizen or lawfully present immigrant, and any related liability, on the other.

The judge left in place the part of the law authorizing local law enforcement officials to question the immigration status of anybody they detain. But the rest of the law will not be implemented on Friday as planned.

The proponents of SB 4 are appealing the injunction, so stay tuned.