The bill now goes to Gov. Jerry Brown for approval.
The issue sparked debate on the Senate floor about when transgender students' right to expression might conflict with other students' discomfort.
Supporters said the bill protects students from bullying, while opponents say the state is going too far.
Even though some schools around the country have similar policies in place, the bill's author says AB1266 would mark the first time a state has required such treatment by statute.
The Associated Press contributed to this report.