The South Dakota state legislature on Tuesday passed a bill that would require public school students to use the bathroom, shower and locker room that correspond to their biological sex.

If Gov. Dennis Daugaard (R) signs the bill, as expected, South Dakota would become the first state to enact such a law.

The bill has provoked outrage from gay and transgender rights activists, who say it discriminates against transgender children. They say that it could put schools at risk of lawsuits; in 2014, the Education Department issued guidance finding that Title IX, the federal law that requires equal treatment of the sexes in schools, requires that students be permitted to use facilities that match their gender identity.

But the bill’s proponents have argued that the legislation actually matches up better with the original language of Title IX, which requires separate facilities for the sexes. They say it respects privacy while also meeting the needs of transgender students by requiring that schools allow them to use private facilities, such as a teacher’s or nurse’s bathroom.

The bill, which passed the state Senate 20 to 15, is just one example of how the debate over gay and transgender rights has shifted since same-sex couples won the right to marry, state by state at first and then nationally when the Supreme Court ruled that marriage was a constitutional right for gay couples.

Opponents of same-sex marriage have sought to shore up protections for businesses and people who object to such unions on religious grounds. The most high-profile fight on this occurred last spring in Indiana, where lawmakers and the governor were forced to backtrack after the law they crafted was decried as anti-gay.

The victory on marriage has also thrust into center stage the debate over the rights of transgender people, who have gained more social acceptance in recent years but still struggle with discrimination in the workplace and elsewhere.

The issue of transgender people and bathrooms has flared up recently, particularly after Houston voters last year repealed an anti-discrimination ordinance that had been decried as a “bathroom bill.”

The ordinance was designed to give gays, minorities and others an avenue to fight discrimination in employment and other arenas. But critics, citing a provision barring discrimination against transgender people in public accommodations, successfully argued that the measure would give sexual predators access to women’s restrooms.

The issue of transgender people and bathrooms has become particularly charged when it comes to schools. Across the country, districts have adopted varying policies for allowing transgender students the use of sex-segregated locker rooms and bathrooms and membership on sports teams.

In several instances, the policies have led to lawsuits. Earlier this year, the U.S. Court of Appeals for the 4th Circuit in Richmond heard arguments in the case of Gavin Grimm, a transgender 16-year-old barred by his school district from using the boys’ bathroom, which corresponds with his gender identity. The policy required him to use the girls’ restroom or a private restroom.

A federal judge had previously rejected Grimm’s request for a preliminary injunction that would have allowed him to use the boys’ restroom. Grimm and his attorneys with the American Civil Liberties Union appealed the decision.

Dozens of school districts have grappled with this issue, but South Dakota would be the first to make it a matter of state law. About a dozen states are considering similar legislation, according to the Human Rights Campaign.

“I do think that to some extent there is a network of people who are anti-LGBT who are feeling emboldened by the messaging success they enjoyed in Houston and are spreading that to other places,” said Cathryn Oakley, HRC’s senior legislative counsel.

The bill does not carry any penalty for students or schools that violate the law. But the true punishment, Oakley said, is that the schools would probably get snarled in costly legal fights as courts resolve the conflict in state law and the guidance from President Obama’s administration on Title IX.

Oakley and others argue that forcing transgender students to use separate bathroom facilities is not a reasonable accommodation. They say it can be inconvenient for a student to venture far away from his or her classes to a designated bathroom. Moreover, they say, it further stigmatizes the students as different from their peers.

But Matt Sharp, legal counsel for the Alliance Defending Freedom, a Christian legal organization that advised the South Dakota legislature on the bill that passed Tuesday, said the attempt to create an accommodation “shows compassion for transgender students” while protecting the privacy of the rest of the student body.

Sharp cited the Virginia legal decision and others as evidence that courts were rejecting the Obama administration’s interpretation of Title IX. Still, he said, schools and districts are concerned because in extreme cases the Education Department could revoke an institution’s federal funding.

To ease their worries, the organization has offered to represent pro bono any district that finds itself in legal trouble over its decision to abide by the new state law.