Texas lawmakers approved a bill Wednesday that outlaws so-called “sanctuary cities” and jurisdictions in Texas and allows law enforcement to ask people about their immigration status of anyone they legally detain.

In a 20-11 vote, the Texas Senate backed hard-line provisions to the bill that had previously prompted “emotional warfare” on the state House floor, The Dallas Morning News reported>, when Democratic lawmakers’ effort to soften the measure failed.

Known as Senate Bill 4, the legislation is all but guaranteed to become law. Shortly after the ban won final approval, Gov. Greg Abbott wrote on Twitter that, “I’m getting my signing pen warmed up.”

The Texas sanctuary city ban wins final legislative approval. I'm getting my signing pen warmed up. #txlege #tcot https://t.co/OHmspC5Zhz — Greg Abbott (@GregAbbott_TX) May 4, 2017

What does the bill actually say?

Bill supporters said sanctuary cities that refuse to cooperate with the nation’s immigration laws enable immigrants to commit crimes before they’re deported. Immigrant advocates said the bill has some of the nation’s toughest penalties, adding that it’s comparable to Arizona’s 2010 “show me your papers” law, which was later amended.

Here’s what the bill does:

Grant police officers the authority to question a detained person’s immigration status, even during a minor offense.

Law enforcement officials and local leaders face criminal charges if they prevent police from inquiring about a person’s immigration status or refuse to enforce immigration laws.

Cities, counties and colleges face heavy fees for resisting as well: $1,000 for a first offense and then civil penalties up to $25,500 for each violation.

What were the reactions to the bill’s passage?

State Sen. Charles Perry, who authored the bill, praised its passage and said it is meant to protect Texans.

“Banning sanctuary cities is about stopping officials who have sworn to enforce the laws from helping people who commit terrible crimes evade immigration detainers,” Perry said in a statement.

Travis County Sheriff Sally Hernandez has been an outspoken critic of the bill. During her 2016 campaign, she promised not to cooperate with Immigration and Customs Enforcement’s requests to detain undocumented immigrants unless they had a warrant.

After President Trump was sworn in, one Texas sheriff made a policy change limiting cooperation with agents from Immigration and Customs Enforcement, fearing undocumented people won’t trust police if they’re afraid of being deported. Taking action to make her city a “sanctuary” has drawn criticism and retaliation. William Brangham reports.

“I am disappointed, because this is not in the best interest of public safety,” Hernandez said in a statement after the Texas bill passed the state legislature. “It ties the hands of our law enforcement agency and pushes victims of crime into the shadows.”

But Hernandez agreed to comply with the Texas law.

How did we get here?

Then-Gov. Rick Perry brought the issue to the state legislature in 2011, saying he wanted to “abolish sanctuary cities in Texas.” Despite legislation being proposed multiple times since then, it failed to pass until this year, when the national debate over sanctuary cities gave supporters momentum.

President Donald Trump made cracking down on illegal immigration a cornerstone of his campaign and signed an executive order earlier this year to withhold federal funds from cities that refuse to cooperate with U.S. immigration officials. A federal judge struck down that order last month. Attorney General Jeff Session vowed to appeal the ruling, saying the deportation of undocumented immigrants who committed crimes is within the national interest.

Sessions has taken an unyielding stance against sanctuary cities, which he has pledged to aggressively target.

“We’re going to put pressure on these cities,” Sessions said in an interview with Fox News in April. “We’re going to battle them every step of the way.”

The debate has sparked action from cities and states across the country. California’s legislature is considering a bill that would prohibit state and local law enforcement from using resources to assist immigration authorities. Indiana lawmakers passed a measure that bans colleges and universities from officially pledging not to cooperate with immigration officials. Colorado killed a bill Wednesday that, like Texas’ measure, would have withheld state funding from cities that protect undocumented immigrants.

Correction: The headline incorrectly stated that the state of Texas banned so-called “sanctuary cities.” However, at this time, Senate Bill 4 has passed through Texas legislature, but still requires the governor’s signature.

READ MORE: Where does the immigration debate stand under President Trump?