SACRAMENTO, California (Reuters) - California's state Assembly approved a bill on Tuesday to prohibit children and teenagers from undergoing a controversial therapy that aims to reverse homosexuality, moving the state closer to becoming the first to impose such a ban.

The 51-21 vote in the Democratic-controlled Assembly marked a major victory for gay rights advocates who say the so-called conversion therapy has no medical basis because homosexuality is not a disorder.

Opponents of the practice say such attempts to change sexual orientation can cause depression and lead to substance abuse and suicide.

Several openly gay legislators championed the bill in emotional speeches during the floor debate, citing their own childhood experiences.

"One of our No. 1 priorities in this house is to protect the next generation of Californians," said Ricardo Lara, a Democrat from Los Angeles County. "And some of those are sissy boys. And some of those sissy boys grow up to be Assembly members. And some of those sissy boys need help. And we are here to stand with those sissy boys."

The Senate passed its version of the bill by a vote of 23-13 in May. Lawmakers must iron out minor differences in the two measures by Friday before a final bill makes its way to the desk of Democratic Governor Jerry Brown.

Brown has not indicated whether he supports the measure, and a spokesman for the governor said that he would not comment on pending legislation.

Assembly member John Perez, the first openly gay speaker of the California's lower house, said during floor debate that "it is inappropriate for anyone, including parents, to subject anybody to dehumanizing activity," referring to the therapy.

The bill's sponsor, state Senator Ted Lieu, said in a statement that the psychiatrist who pioneered such therapy, Dr. Robert Spitzer, has since renounced it and apologized to the gay and lesbian community.

If Brown signs the bill into law, California would become the first state in the nation to outlaw such therapy for minors.

Republican opponents of the measure said politicians should not step in and regulate what they consider to be a matter for medical boards to decide. They also said the bill encroaches on the rights of parents to make choices for their children.

"That's why parents have children -- to hand down their legacies, their belief systems, the way they want their children raised," Assembly member Shannon Grove, a Republican from Bakersfield, said during the floor debate.

(Reporting by Mary Slosson; Editing by Cynthia Johnston and Stacey Joyce)