Follow KRLD: Facebook | Twitter

AUSTIN (AP) – The Republican-controlled Texas House approved early Thursday a strict ban on “sanctuary cities” in the country’s second-largest state, seeking to empower law enforcement to enforce federal immigration law against anyone they detain and threatening to jail police chiefs and sheriffs who refuse to do so.

READ MORE: Increased Monthly Child Tax Credit Payments To Start In July

The vote came just before 3 a.m. and followed 15-plus hours of heated, sometimes tearful debate, much of it from outnumbered Democrats.

The bill would allow Texas to withhold funding from county and local governments for acting as sanctuary cities — even as the Trump administration’s efforts to do so nationally have hit roadblocks. Other Republican-led states have pushed for similar polices, but Texas would be the first in which police chiefs and other officials could face criminal charges and be removed from office for not helping enforce immigration law.

The proposal is needed to “keep the public safe and remove bad people from the street,” said Republican Rep. Charlie Geren of Fort Worth, its House sponsor.

The term “sanctuary cities” has no legal definition, but Republicans want local police to help federal authorities as part of a larger effort to crack down on criminal suspects in the U.S. illegally.

The Texas House bill originally allowed local law enforcement officers to inquire about federal immigration status only if someone is arrested. A version passed in March by the state Senate went further, permitting immigration inquires of anyone who is detained, including during traffic stops.

But a tea party-backed floor amendment extending the House version to apply to those detained as well as those arrested passed on an 81-64 vote — bringing the full bill closer to what the Senate approved previously.

Democrats, and even some veteran Republicans, opposed the change to no avail. It drew rebuke from the Texas Catholic Conference of Bishops which tweeted, “We’re disappointed House voted to allow police to inquire into legal status during detention rather than arrest.”

President Donald Trump is trying to withhold federal funding for sanctuary cities, but on Tuesday, a federal judge in California issued a preliminary injunction preventing him from doing so. Texas Gov. Greg Abbott has declared the issue an “emergency” item, and the state is poised to pass an anti-sanctuary cities law regardless of what happens nationally.

Sally Hernandez, the sheriff of Travis County, which includes liberal Austin, enraged conservatives by refusing to honor federal requests to hold suspects for possible deportation if they weren’t arrested for immigration offenses or serious crimes such as murder. But Hernandez softened her policy after Abbott cut grant funding to the county and she has said she’ll conform to the state’s ban if it becomes law.

Other sheriffs warn the bill could make their jobs harder if immigrant communities — including crime victims and witnesses — fear the police.

“Today we’ve made real that fear,” said Roland Gutierrez, a San Antonio Democrat. Many of his colleagues decried what they called a “show me your papers law.”

Wednesday night, dozens of protesters, many waving signs and banners skewering the bill and its supporters, gathered inside the Texas Capitol to chant pro-immigrant slogans in English and Spanish. Some later filed into the House visitors’ gallery to applaud bill opponents on the floor. “God is watching what you’re doing,” one woman yelled at Republican lawmakers before being escorted out.

Things had quieted hours later, when the bill was approved. Still, Democratic Rep. Mary Gonzalez of El Paso, on Texas’ border with Mexico, wept openly as she recalled being sexually assaulted, saying the bill will empower criminals. Rep. Victoria Neave, a Dallas Democrat, staged a four-day fast in opposition.

“I have seen the fear of children who worry their parents are going to be deported,” Neave said.

The state Senate’s version is different enough from what the House passed that the two chambers must compromise before sending a bill to the governor. Similar efforts have collapsed in the past, though, meaning the issue isn’t yet fully settled.

MORE NEWS: Flash Flood Watch As Weeklong Wet Weather Stretch Drenches North Texas

(© Copyright 2017 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)