Some school districts around the country have implemented similar policies, but the bill's author says AB1266 would mark the first time a state has mandated such treatment by statute.
Existing state law already prohibits California schools from discriminating against students based on their gender identity, but the legislation that passed the state Senate on Wednesday spells that out in more detail, said Carlos Alcala, a spokesman for the bill's author, Democratic Assemblyman Tom Ammiano of San Francisco.
At least one other state education department, in Massachusetts, has a policy granting the same protections.
The bill would give students the right "to participate in sex-segregated programs, activities and facilities" based on their self-perception, regardless of their birth gender.
It sparked an impassioned debate on the Senate floor about when transgender students' right to expression might conflict with other students' discomfort and right to privacy.
Supporters said the bill is needed to protect students from bullying and other abuse. They also said it represents the next front in their effort to provide equal rights for lesbian, gay, bisexual and transgender individuals, just days after same-sex marriages resumed in California.
Opponents said the state is going too far if it permits opposite-sex students to use restrooms and locker rooms.
"It is not all about discrimination. Elementary and secondary students of California our most impressionable, our most vulnerable now may be subjected to some very difficult situations," said Republican Sen. Jim Nielsen.
The Senate passed the bill on a vote of 21-9. It previously passed the Assembly and now goes to the governor.