California law protects rights of transgender students
California has become the first US state to enshrine rights for transgender schoolchildren.
A new law requires public schools to allow pupils from kindergarten to the 12th grade to access male or female toilets according to their preference.
The legislation also allows transgender schoolchildren to choose whether to play boys' or girls' sports.
State Assembly Speaker John Perez said it put "California at the forefront of leadership on transgender rights".
Massachusetts and Connecticut have state-wide policies granting the same protections, but California is the first to put them into law.
Supporters of bill AB1266, which gives transgender schoolchildren the right to "participate in sex-segregated programs, activities and facilities", argued that it would help reduce bullying and discrimination.
School districts in Los Angeles and San Francisco already had similar polices and had reported no problems, they noted.
Opponents of the legislation said allowing pupils of one gender to use facilities intended for the other could invade the others students' privacy or violate their rights.
"Will transgender students make some other children uncomfortable? Perhaps," said the bill's author, Democratic Assemblyman Tom Ammiano.
"I don't want to minimise that, but new experiences are often uncomfortable. That can't be an excuse for prejudice."
Families of transgender children have been fighting battles with school districts across the US over access to toilets and changing rooms.
In June, a civil rights panel in Colorado ruled that a school had discriminated against a six-year-old transgender girl by barring her from using the girls' toilets.