There are no specific laws on child custody regarding whether or not a gays or lesbians can be awarded or denied custody, based on their sexual orientation. With that said, it is not uncommon for a judge to rule against a person who is gay, based on his / her own bias on the subject. What this means is that judge, in most states, can not rule specifically based on a persons sexual orientation but they can, and often do, rule against those people for other reasons.
If a judge should rule against a gay or lesbian parent who shows otherwise exemplary and upstanding behavior as a parent, and member of society, that parent can appeal the courts decision. There are may gay rights groups that will be more than happy to become involved in such a case if there is any hint of discrimination alleged. This is especially true if the person who was denied custody met every other requirement as a fit parent under the laws on child custody of that particular state.
Typically, if a person can prove that discrimination was present during any court proceedings, they can successfully have the court's decision over turned, and are usually entitled to a new hearing. The same is true for parents who feel they have been discriminated against based on race or religion according to the laws on child custody. The only thing a court should be focused on is what is in the best interest of the child in question. Unfortunately, this is not always the case.
If you are a gay or lesbian parent who suspects that they have been denied custody of their child based on their sexual orientation, you may want to contact your local gay / lesbian rights group to find out what type of assistance they may offer you in having the courts ruling over turned.