Updated

Texas Gov. Greg Abbott signed a bill Sunday prohibiting the state's cities and counties from enacting so-called "sanctuary" laws that prevent local law enforcement officers from inquiring about the immigration status of anyone they detain.

Abbott took the unusual step of signing the bill on Facebook with no advanced public notice. He said Texas residents expect lawmakers to "keep us safe" and said similar laws have already been tested in federal court, where opponents have already been hinting the bill will be immediately challenged.

"Let's face it, the reason why so many people come to America is because we are a nation of laws and Texas is doing its part to keep it that way," Abbott said.

SANCTUARY CITIES BILL PUTS TEXAS COUNTY IN TIGHT SPOT

The timing of the signing caught Democratic lawmakers flatfooted. Democratic state Rep. Cesar Blanco said it looked like Abbott "wanted to get ahead" of any protests surrounding the bill signing. Abbott spokesman John Wittman said they chose to sign the bill on a Facebook livestream because that's "where most people are getting their news nowadays."

Protests over the bill have been intense for months and about 20 people were charged with criminal trespassing last week after staging a daylong sit-in at a state building where some of Abbott's staff works. One Democratic state representative embarked on a three-day hunger strike in protest.

Teri Burke, executive director of the ACLU of Texas, said "we will fight this assault in the court" and the ballot box. Abbott said key provisions of the bill had already been tested at the U.S. Supreme Court, which struck down several components of Arizona's law but allowed the provision permitting police to ask about immigration status.

Republicans say the bill is needed to ensure local jails honor requests from federal officials to keep dangerous offenders behind bars.

TEXAS, CALIFORNIA TAKE VERY DIFFERENT APPROACHES TO 'SANCTUARY CITY' DEBATE

The bill allows police to inquire about the immigration status of anyone they detain, a situation that can range from arrest for a crime to being stopped for a traffic violation. It also requires local officials to comply with federal requests to hold criminal suspects for possible deportation.

One of the bill's most controversial provisions allows for criminal charges against city or county officials who intentionally refuse to comply with federal authorities' attempt to deport people in the country illegally who already have been jailed on offenses unrelated to immigration. Elected officials could face up to a year in jail and lose their posts if convicted of official misconduct.

Opponents blasted the Texas bill as a version of Arizona's immigration crackdown law, SB 1070, which launched protests, lawsuits and national controversy in 2010. The Arizona law went to the U.S. Supreme court, which voided much of the measure but allowed the provision permitting police to ask about immigration status.

But the Texas and Arizona bills are not identical. Whereas the Arizona law required police to try to determine the immigration status of people during routine stops, the Texas bill doesn't instruct officers to ask. But it does allow Texas police to inquire whether a person is in the country legally, even if they're not under arrest.

Every major police chief in Texas opposed the bill. Thomas Saenz, president of the Mexican American Legal Defense and Education Fund, said millions in the nation's second most populous state will now be subjected to racial profiling and suggested that worried Hispanic residents will now be less willing to cooperate with police investigations.

"Given the size of the state, this may well be the most costly gubernatorial signature in all of United States history," Saenz said.

Some Democrats said the timing of the signing particularly stung after three recent federal court rulings that found intentional discrimination in Republican-passed voting laws.

"They did not connect the history of our culture or how closely that it is tied to Mexico," Democratic state. Rep. Eddie Rodriguez said. "It's just extremely personal. There is a lot of disconnect. They don't really see this as affecting people."

Texas doesn't currently have any cities which have formally declared themselves sanctuaries for immigrants.

But Sally Hernandez, the sheriff of Travis County, which includes liberal Austin, enraged conservatives by refusing to honor federal detainer requests if the suspects weren't arrested for immigration offenses or serious crimes such as murder. Hernandez softened her policy after Abbott cut funding to the county, saying decisions would be made on a case-by-case basis. She has said she will conform to the state's ban if it becomes law.

The Associated Press contributed to this report.