Under the current law of almost all states, mothers and fathers have an equal right to custody. Courts are not supposed to assume that a child is automatically better off with the mother or the father. In a contested custody case, both the father and mother have an equal burden of proving to the court that it is in the best interest of the child that the child be in his or her custody.
There are a few states (mostly in the South) that have laws providing that if everything else is equal, the mother may be preferred; but in those states, many fathers have been successful in obtaining custody, even if the mother is a fit parent.
In some states, courts say that mothers and fathers are to be considered equally, but the courts then go on to hold that it is permissible to consider the age or sex of the child when deciding custody. That usually translates to a preference for mothers if the child is young or female. But, again, it is possible for fathers in those states to gain custody, even when the mother is fit.