If the bill is adopted by the state Assembly and signed by Gov. Jerry Brown, California would become the first state to require the teaching of gay history.
Supporters say the move is needed to counter anti-gay stereotypes and beliefs that make children in those groups vulnerable to bullying and suicide.
Opponents counter that such instruction would further burden an already crowded curriculum and expose students to a subject that some parents find objectionable.
The legislation, sponsored by Democratic Sen. Mark Leno of San Francisco, passed on a 23-14 party line vote. It also would add disabled people to the curriculum.
The bill gives school districts flexibility in deciding what to include in the lessons and at what grades students would receive them.
But starting in the 2013-14 school year, it would prohibit districts and the California Board of Education from using textbooks or other instructional materials that reflect adversely on gay, bisexual and transgender Americans.
Appealing to colleagues for support, Leno said gay children still struggle routinely with verbal and physical abuse at school, even though society is more accepting than when he was a gay youth in the 1960s.
"We are second-class citizens and children are listening," he said. "When they see their teachers don't step up to the plate when their classmate is being harassed literally to death, they are listening and they get the message that there is something wrong with those people."
Republican Sen. Doug La Malfa of Butte opposed the bill.
"I'm deeply troubled kids would have to contemplate at a very, very early age, when many of us are teaching abstinence ... what is sexuality," he said.
California law already requires schools to cover the contributions to the state and nation of women, African Americans, Mexican Americans, entrepreneurs, Asian Americans, European Americans, American Indians and labor.