Updated at 12:00 p.m. to reflect final passage in the Texas House.

AUSTIN — The Texas House has approved a bill that will keep transgender public school children from using the restroom that matches their gender identity.

The measure, a Republican deal on the “bathroom bill,” passed the GOP-dominated chamber by a vote of 94-50. If the Senate agrees to the measure, and Gov. Greg Abbott doesn’t veto it, Texas will become the second state in the nation to pass such legislation.

Debate took place late Sunday night and Monday afternoon, when the measure was given final approval. Discussion was emotional and divisive, with Democrats likening it to a Jim Crow-era attack on defenseless kids and Republicans insisting the measure did not single out or target anyone.

Amendment to keep #transgender kids out of bathrooms that match gender ID passes 91-50. #txlege pic.twitter.com/1tsXjvVvmB — Lauren McGaughy (@lmcgaughy) May 22, 2017

“America has long recognized that separate but equal is not equal at all,” said Rep. Senfronia Thompson, a Houston Democrat who has served in the House since 1972. “What’s wrong with treating kids with equality and not making them feel like they are second-class citizens?”

"Transgender students are God's business, and you know what, He loves them, too."

The measure would keep transgender kids from using multi-occupancy school bathrooms and locker rooms that match their gender identity, unless no one else is present. If other children are around, they’d have to use a different, single-use restroom elsewhere in the school.

Currently, school districts and charter schools in Texas draw up their own plans for accommodating transgender students. Many tackle the issue on a case-by-case basis. After the vote Sunday, the Texas Association of School Boards called the measure a "a common-sense solution."

{"type":"video","title":"Dallas News Video","author_name":"Dallas News","_id":"13N2NiYjE60T-jW1wJcTx8DLFoj4pi7j","provider_name":"Ooyala","html":"

","raw":"{\"type\":\"video\",\"title\":\"Dallas News Video\",\"author_name\":\"Dallas News\",\"_id\":\"13N2NiYjE60T-jW1wJcTx8DLFoj4pi7j\",\"provider_name\":\"Ooyala\",\"html\":\"\\u003Cdiv class=\\\"oo-vid-container\\\" data-oo-content-id=\\\"13N2NiYjE60T-jW1wJcTx8DLFoj4pi7j\\\"\\u003E\\u003C\\/div\\u003E\\u003Cscript defer src=\\\"https:\\/\\/www.dallasnews.com\\/resources\\/motif\\/dist\\/js\\/ooyala.js\\\"\\u003E\\u003C\\/script\\u003E\"}","providerType":"ooyala","providerLink":"https://www.dallasnews.com/oembed","embedType":"video"}

"The language captures in law a solution many districts already use locally, seeking a balance between ensuring privacy and security for all students and respecting the dignity of all students," TASB Assistant Director of Government Relations Dax González said in a prepared statement.

The bathroom language was amended onto another public school bill, one that requires schools to draw up natural disaster and emergency preparedness plans. Rep. Chris Paddie, R-Marshall, authored the amendment.

Here is the bathroom bill amendment that is being debated right now in the Texas House. https://t.co/z32LOU6sKP #txlege #LGBT #transgender pic.twitter.com/cG8DkS4H8l — Lauren McGaughy (@lmcgaughy) May 22, 2017

“There is absolutely no intent, and I would argue nothing in this language discriminates against anybody,” said Paddie. “We want to make sure we provide definitive guidance to our school districts.”

The fight over lesbian, gay, bisexual and transgender rights this year has been particularly divisive in Texas. Lt. Gov Dan Patrick, who heads the Senate, began pushing a bathroom bill last year, but House Speaker Joe Straus has called the effort unnecessary and damaging to business.

With the session winding to a close May 29, Patrick threatened to hold the state budget and another must-pass bill hostage if the bathroom bill wasn't approved in the House. The bathroom measure that passed Sunday was the product of that ultimatum, a proposal more limited than Patrick wanted, but palatable enough to receive the backing of a majority of House Republicans.

The Senate's version of the bathroom legislation would have barred transgender Texans from using the bathroom they want in all government buildings, public schools and colleges and universities. That measure went nowhere in the House.

Earlier this year, a House committee debated a version of the legislation that would have undone city laws regulating bathrooms and dressing rooms. That measure, too, died before it was debated on the House floor.

Late Sunday, Straus said he hoped the bill passed Sunday would "allow us to avoid the severely negative impact of Senate Bill 6. Members of the House wanted to act on this issue and my philosophy as Speaker has never been to force my will on the body."

Democrats tried repeatedly to kill the Paddie amendment, or the larger bill, Sunday night. They failed each time. Far-right Republicans, self-styled the Texas Freedom Caucus, were expected to try to make the amendment broader. They did not.

As the debate stretched into the evening, emotions of House members who are now working seven days a week, often late into the night, bubbled over. Democrats accused Republicans of claiming there was a "middle ground" on discrimination. Republicans insisted they didn't intend to target transgender children.

Rep. Jason Villalba, R-Dallas, unexpectedly spoke in favor of the amendment about an hour into the debate. He had tweeted early in the night that he'd vote against the bathroom bill or anything like it, but the Paddie amendment, he said, was fair.

"I am no fan of any kind of legislation that would discriminate, dehumanize, belittle or treat anyone differently merely because of the way they live their lives," Villalba, who earlier this session was the only Republican to vote for bill extending greater rights to LGBT Texans. "It is not the bathroom bill."

Paddie defended his amendment, saying it "treats all children the same." But he was rebuked by El Paso Democrat Rep. Joe Moody, who pointed to the amendment's language that singles out students who don't want to use the bathroom that corresponds to their biological sex.

"This amendment is the bathroom bill. And the bathroom bill is an attack on transgender people. Some people don't want to admit it. Maybe that's because they're ashamed and make no mistake about it," Moody said. "This is shameful."