California lawmakers have passed a bill allowing transgender students to use bathrooms and gain sports team memberships according to their gender identity.

The bill, AB1266, was previously passed by assembly in May alongside another bill that would create an administrative alternative for transgender people to amend their birth certificates without facing lengthy and legal processes.

On Wednesday, the bill allowing transgender students to use bathrooms and gain membership to sports team memberships was voted in favour 21 to 9 in the California Senate, although it was largely opposed by State Republicans.

The bill states that students, “be permitted to participate in sex-segregated school programs and activities, including athletic teams and competitions, and use facilities consistent with his or her gender identity, irrespective of the gender listed on the pupil’s records.”

Republican Senator Jim Nielsen, who opposed the bill, told radio station KCRA the measure would expose teens to being molested. “There are youthful sex offenders,” Mr Nielsen told KCRA. “I guarantee there would be those who would use this opportunity.”

Other Republicans argued that less capable male athletes might join girl teams to gain a competitive edge.

The bill has been sent to California Governor Jerry Brown, whose office has not yet stated whether he will sign it into law.

If signed into law California would become the first US state to create a legal right to access public school facilities and activities based on gender identity although other states already have general policies allowing it.