The Mexican government, San Antonio's police chief and others slammed Texas' new "sanctuary cities" law on Monday, saying that requiring local law enforcement to help enforce U.S. immigration law could lead to racial profiling and will fan distrust of the police by the state's many Hispanics.

The law, which takes effect in September and which critics say is the most anti-immigrant since a 2010 Arizona law, will allow police officers to ask about the immigration status of anyone they detain, including during routine traffic stops. Republican Gov. Greg Abbott signed the law Sunday evening on Facebook Live with no advanced warning. A few dozen people protested outside his mansion in Austin on Monday.

San Antonio police chief William McManus, whose burgeoning city is estimated to have more than 1 million residents who aren't in the country legally, ripped into the Republicans who pushed the law through despite the objections of every big-city police chief in the state.

He and the other police chiefs, including those in Dallas and Houston, say it will create a chilling effect that will cause immigrant families to not report crimes or come forward as witnesses over fears that talking to local police could lead to deportation. Critics also fear it will lead to the racial profiling of Hispanics and put officers in an untenable position.

"It's either skin color or language. What else does someone have to base it on?" McManus said, referring to an officer's reason for inquiring about a person's immigration status. "That leads to profiling. Profiling leads to lawsuits. In my opinion, there is nothing positive this bill does in the community or law enforcement."

Nevertheless, McManus said his department will abandon a policy that prohibits officers from asking about a person's immigration status.

"We're going to have to take it off the books," said McManus, adding that it will probably have to spend a year now training his roughly 2,400 officers on immigration law.

The law also drew rebuke from Mexico, which is Texas' largest trading partner and shares close ties to the state. The country's foreign ministry said in a news release that the law could trample on the rights of Mexican citizens who choose to live just across the border and promised to "closely follow" the situation after the law takes effect.

"These types of actions criminalizes even more the topic of immigration, foments racial discriminatory acts and reduces collaboration between the immigrant community and local authorities," the ministry said.

The law also requires police chiefs and sheriffs — under the threat of jail and removal from office — to comply with federal requests to hold criminal suspects in jail for possible deportation. Republicans have a strong majority in the Legislature and shoved aside Democratic objections, even as President Donald Trump's efforts to withhold federal funding for sanctuary cities have hit roadblocks in federal courts.

"Isn't this quasi-insane that we have to pass a law to force law enforcement officers to comply with the law?" Abbott said Monday on "Fox and Friends."

Terri Burke, executive director of the ACLU of Texas, said the group is committed to fighting the law. But it remained unclear Monday when it might file a lawsuit.

The term "sanctuary cities" has no legal definition, but Republicans want local police to help federal immigration agents crack down on criminal suspects in the U.S. illegally.

Opponents blast the Texas bill as a version of Arizona's immigration crackdown law, SB 1070, which sparked protests and led to legal challenges in 2010. But the Texas and Arizona bills are not identical. Whereas the Arizona law originally required police to try to determine the immigration status of people during routine stops, the Texas bill doesn't instruct officers to ask.

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, has refused to honor federal requests to detain immigrants 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 said before Abbott signed it that she would conform to the ban if it became law.

Associated Press writer Will Weissert contributed to this report.