AUSTIN — The Texas Senate on Wednesday accepted the House's version of a controversial "sanctuary cities" ban, shuttling the bill to Gov. Greg Abbott's desk for a final stamp of approval.

Abbott declared the ban an emergency legislative item in January and has said he looks forward to signing the bill. It would take effect Sept. 1, more than six years after Republican lawmakers first tried to pass such a ban in 2011.

"The Texas sanctuary city ban wins final legislative approval," Abbott tweeted Wednesday night. "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

"I have been working to end sanctuary cities in Texas since my days as a state senator," GOP Lt. Gov Dan Patrick said in a prepared statement.

Democrats have decried the bill as hateful and discriminatory, comparing it to Arizona's contentious "papers please" legislation. After losing their fight to stop the law in the Legislature, they have promised to take their battle against it to court.

Senate Bill 4 would punish cities, counties and universities that prohibit local law enforcement officers from asking about a person's immigration status or enforcing immigration law. It would create a criminal charge for police chiefs, county sheriffs and constables who violate the ban and would fine local jurisdictions up to $25,000 a day for each violation. Perhaps the most offensive feature of the bill to Democrats, though, is a provision that would allow police to question anyone they detain about their immigration status.

Proponents of the ban say it is necessary to keep criminal immigrants off Texas streets. If local law enforcement officials don’t turn over unauthorized immigrants to federal authorities, they argue, those people could go on to commit more serious crimes.

Critics, including police chiefs and sheriffs in some Texas' largest cities, contend the legislation would create a rift between police and immigrant communities, who would be afraid to report crimes for fear of being deported. Opponents also say the bill condones racial profiling and discrimination against the state’s growing Latino population.

Sen. Sylvia Garcia, D-Houston, said the bill would allow officers to stop people for "walking while brown."

"It doesn’t matter how much the supporters of this bill promise that this will not happen," she said. "It will happen, and in some parts of my home district it already is happening."

The bill's author, Sen. Charles Perry, R-Lubbock, called Democrats' arguments "fearmongering" and "sensationalism." He said the bill simply allows local law enforcement to act on existing laws.

"You've made it look like a demon that it is not," he told senators who opposed its passage.

The Senate version of the bill, approved in February, would have cut state funding to jurisdictions that violate the ban. That version also would have created a criminal charge for local elected officials who made policies that violated the ban and would have allowed victims of crimes committed by unauthorized immigrants to sue cities and counties that released them despite a request from immigration authorities to hold them.

Democrats and moderate Republicans in the House tried to soften the Senate’s version of the bill. They removed several of the toughest provisions during the chamber’s committee process and tried to strike a deal with Democrats to pass a more tempered version during House debate last week.

But when negotiations around that deal broke down, the House approved a bill that is arguably stronger than the Senate's. That is the version now destined for Abbott's signature.

It does not include provisions to pull state funds from local jurisdictions or allow crime victims to sue cities and counties. But it does allow law enforcement officers to ask about a person’s immigration status during any legal detention.

Critics of the law have called it unconstitutional. The final version of the bill also includes a provision to remove from office elected and appointed officials who violate the ban — a pet objective of Abbott’s.

As the Senate debated whether to accept the changes made by the House, Sen. John Whitmire, D-Houston, said he was concerned about the "routine" nature of the discussion around a controversial bill that could have unintended consequences. Republicans, who support the ban, hold a 21 to 10 majority in the chamber.

"Where’s the anxiety?" Whitmire said. "Where’s the worry about unintended consequences?"

Perry replied that he did worry but was forced to file the legislation by local jurisdictions that had blocked their officers from enforcing existing immigration law.

"You don’t see me in my private time. I do have that angst. I do feel that," he said. "But at the same time, can you appreciate the angst to see our civil system and our criminal system undermined by people that say we don’t do it that way anymore?"

But law enforcement groups, including the Texas Police Chiefs Association and the sheriffs of major counties such as Dallas, Travis, Harris and El Paso, oppose the bill and have said it will make their jobs more difficult by creating distrust of their officers.

Perry contested claims that the bill would sew such distrust, because he said it would limit police from asking about a person's immigration status if he or she is a witness to or victim of a crime.