Updated: This post has been updated to reflect the Texas Senate's vote Wednesday.

AUSTIN — The Texas Senate has officially passed the so-called bathroom bill, a controversial measure that has divided lawmakers and caused an uproar in the LGBT community.

After more than 4 1/2 hours of debate Tuesday, the bill was given preliminary approval by a vote of 21-10, mostly along party lines. One Democrat, Sen. Eddie Lucio Jr. of Brownsville, broke with his party and voted in favor of the bill.

On Wednesday, the Senate voted 21-10 to formally approve the bill and send it to the Texas House, which is also Republican-dominated but whose members are far less eager to take up the legislation.

“Don’t think I don’t pray about this and make sure we’re making the right decision,” Sen. Lois Kolkhorst, the Brenham Republican who is sponsoring the bill, said Tuesday. “I think it is incumbent upon us to give guidance.

"The people of Texas expect boundaries between gender."

Her legislation, Senate Bill 6, would require people to use restrooms in public schools, universities and government buildings that match the "biological sex" noted on their birth certificates. The bill would apply to places like the state Capitol in Austin, city halls, state agencies and the thousands of public schools and universities across the state.

It would also nix city ordinances that allow people to use the restrooms, dressing rooms and locker rooms that correspond to their gender identity. The bill would not apply to private businesses or public buildings that are leased out to private entities, letting them set their own policies.

Senators, mostly Democrats looking to soften what they say are the discriminatory effects of the bill, offered more than 20 amendments Tuesday. All but three were shot down. The most significant change to the bill would require anyone who files a complaint that a school or government agency isn’t following the law to sign a sworn affidavit they are telling the truth.

Debate this week was largely polarized, with Democrats insisting the bill would discriminate against the transgender community and drive away businesses and sporting events. Republicans countered that the bill is meant to increase public safety and protect privacy, particularly of women and girls.

Some supporters in the Senate said the bill is not meant to curb bathroom access for transgender Texans, while other acknowledged, yes, that is indeed what the measure aims to do.

“This bill is not about the transgender community, although the media and many members have tried to make it about that,” said Sen. Joan Huffman, R-Houston. “We were worried there would be folks who would use that to either stalk victims or terrorize victims.”

It is currently not illegal for a man to enter a woman's restroom, changing or locker room in Texas, said Huffman, a former prosecutor and judge. Only if you commit a lewd act or attack someone would such behavior be illegal under existing law.

Lucio, explaining his vote in favor of the bill Wednesday, said the bill is meant to address the transgender population, especially children. The Trump administration recently rescinded guidelines Texas has fought that would have required schools to allow transgender students to access bathrooms and locker rooms matching their gender identity.

"Children should be allowed to be children," Lucio said, adding government should not "indoctrinate children in gender theories and other mature topics they may not comprehend."

He said everyone sees the bathroom bill differently, either as "a bulwark against society's moral decline or its moral evolution."

"We can be compassionate and fair to all."

Every other Democrat disagreed.

Sen. John Whitmire, a Houston Democrat and the Senate's longest-serving member, on Tuesday called the bill unnecessary from a safety standpoint, saying it is already illegal to harass, accost or assault someone in the bathroom or anywhere else in Texas.

It's not fair to ask a transgender man who was born female to use the women's restroom, he added, bringing up Lou Weaver, a transgender man and activist in Houston. Forcing Weaver, who has a beard and wears men's clothing, to use a ladies' room would be disruptive and dangerous both for Weaver and for the women in the bathroom, Whitmire said.

"That, to me, is a fatal flaw in your legislation," he said. "I'm prepared to stand here until hell freezes over to get an answer."

"I do not have an easy answer for you," Kolkhorst responded. "Nothing is easy about this."

Kolkhorst said transgender people have the option of changing their birth certificates to reflect their identity. She also erroneously stated that transgender people would not need to carry their birth documents around with them because their drivers' licenses reflect the sex on their certificates.

That is not the case for many transgender Texans. Changing the sex on one's drivers license and birth certificate are separate processes, and while many transgender Texans will change their names and gender on their state identification cards, the vast majority have not changed their birth documents.

Sen. Judith Zaffirini, D-Laredo, touched on this Wednesday, saying changing your birth certificate in Texas is legal, but it can be "difficult, expensive, embarrassing and in some cases, impossible to achieve."

"The more I listened, the stronger my opposition grew."

The Republican-dominated Senate shot down 19 proposed changes to the bill, including an amendment that would prohibit people from "investigating" whether someone was in the right bathroom and several to track potential economic backlash from the bill's passage.

Amendment 22 (last 1!) would change enactment of bill from 2017 to 2018 to allow schools/cities to craft policies. Fails. #txlege #sb6 https://t.co/U2uJXRD7BZ — Lauren McGaughy (@lmcgaughy) March 14, 2017

Across Texas, city tourism groups and business organizations have joined together to oppose the bill. They cite warnings from sporting organizations like the NCAA and NFL that passing such legislation could cost them future events and say large corporations with LGBT employees won't want to move or expand here. A dozen groups that planned to hold annual meetings or conventions in Dallas have warned they may pull out if the bill passes.

While the focus for the bill's supporters is on safety, law enforcement groups haven't rallied behind the bill. The state's largest police organizations have noted it's already illegal to assault someone no matter where you do it and said cops have more pressing issues than this.

Debate on the bill in the Senate committee last week drew nearly 2,000 people to the Capitol. The vast majority — 86 percent of those who showed up — opposed the bill. The bill passed easily there as well, 8-1.

During her introduction of the bill Tuesday, Kolkhorst blasted the media for making light of her proposal and said she’s been attacked over her stance on the issue.

“I’ve been subjected to many jokes, everybody snickering and talking about the bathroom bill. They’ve made light of this issue, accusing us of wasting time. I will tell you, as a woman, this is not a joke,” she said. “I don’t mean to be dramatic. This has been one of the toughest journeys.”

Whitmire, speaking just before the final vote Wednesday, directly addressed the parents of transgender children.

"We're losing the battle with this vote today. But I believe this is a civil rights issue ... that I hope I serve long enough and live long enough to see accepted by society and by this Legislature," said Whitmire. "Until we have equality for all, then we're all losers."