In defining sex so expansively, the agencies may have walked themselves into a legal contradiction. Title IX has also been interpreted as saying that schools must not tolerate a “hostile environment” that makes girls feel threatened and could impede their education. If the cisgender girl claims that the transgender girl is invading her privacy in a discomfiting way, that could also constitute a Title IX violation. As the Harvard Law professor Jeannie Suk Gersen wrote in The New Yorker, “The federal government is putting schools in a position where they may be sued whichever route they choose.” And so they have been.

Some schools have accommodated transgender students without incident. But others are struggling. Consider what happened in a school district in Palatine, Ill. The district was investigated by the Department of Education’s Office for Civil Rights and found to have violated a transgender girl’s rights. According to the O.C.R. report, “Student A” made the transition from boy to girl in middle school. By the time she got to high school, she had legally changed her name and begun hormone therapy. The school gave her permission to use the girl’s bathrooms and play on female sports teams. But instead of the school’s three locker rooms, it told her, she would have to use private restrooms.

This did not work out well. Student A felt she missed out on moments of team bonding. One of the bathrooms had to be unlocked for her by teachers or hall monitors, which sometimes, she said, made her late. (The school disputed this.) Most infuriating, she was reprimanded for entering an empty locker room when she needed to rent a gym uniform.

It’s not as if the school didn’t try to accommodate her, by its lights. It outfitted one of her restrooms with lockers and told her she could choose some friends to join her there. But no one wanted to move out of the main locker room, and besides, she said, this setup only highlighted her outsider status.

Why would the school impose such seemingly petty restrictions? It was a matter of protecting students’ privacy rights, the district said (though possibly also a matter of not upsetting parents). The changing areas had too few stalls and too many students, and having Student A there “would expose female students to being observed in a state of undress by a biologically male individual,” and to seeing that individual naked, the district said. Unimpressed, the O.C.R. threatened to take away $6 million in federal funding.

The district backed down, letting Student A into the locker rooms and installing private changing rooms. At that point, 51 families — they insist on anonymity — sued the district and the Departments of Education and Justice in federal court, accusing them of, among other things, creating “an intimidating and hostile environment.” The families asked the court to bar Student A from the locker rooms while the case was pending; the judges have not yet ruled on that request.

A similar lawsuit showed up in a Minnesota federal court last month. It, too, featured a high school locker room; the plaintiffs were also anonymous families. They complained that a transgender girl, “Student X,” danced to music with explicit lyrics — “Milkshake” by Kelis, for example — while twerking, grinding and at least once lifting up her skirt to show off her underwear. When one girl edged away, according to the complaint, Student X made rude comments about her. When she and other girls moved to a different locker room, Student X came in and changed next to them. Student X allegedly asked one girl her bra size and suggested they “trade body parts.” The school eventually told the complainants to use the staff bathrooms.