DALLAS -- Texas lawmakersthat outlaws "sanctuary cities" -- cities that don't enforce federal immigration laws.
The legislative action comes after weeks of heated debate and political jousting.
State Sen. Charles Perry, who co-sponsored the measure, claims this bill will make Texas communities safer.
"It's about protecting our communities. We don't want those individuals that have committed crimes -- illegal or otherwise -- that when they had an opportunity to be locked up for public safety to be released at the discretion of local law enforcement," Perry said.
The bill will give every Texas police officer and sheriff's deputy the power to enforce federal immigration law.
Peace officers can ask the immigration status of anyone under arrest -- or even detained.
Travis County Judge Sarah Eckhardt says the new law will unfairly target Texas' large Mexican and central American communities.
"They feel that they're being hunted," Eckhardt said. "Even the native-born are in fear that they're going to be pulled over and asked by a police officer whether they belong here or not -- even if they've been here for generations."
A Syracuse University project showed that between 2014 and 2016 Texas police complied with federal requests and detained more than 35,000 undocumented people. That's 20,000 more than the state of California detained.
The controversial bill has been criticized by police chiefs from Dallas to San Antonio. Under the measure, officers who exercise discretion and don't comply with federal immigration requests could be charged with a misdemeanor.
"If the state has chosen to conscript us as immigration officials we will have to comply," Eckhardt said.
Texas Gov. Greg Abbott tweeted after his legislative victory: "I'm getting my signing pen warmed up."
Once signed, the law will go into effect on Sept. 1, but opponents plan to fight the measure in court.