child custody: an overview
In the case of divorce, generally, the court having jurisdiction of the divorce proceedings also determines who shall have custody of children from the marriage. (The authority to do so is considered part of the original jurisdiction of the court, and not as a new authority being conferred upon them.) Under the common statutory provision, the parents of a child born within a marriage are joint guardians of that child and the rights of both parents are equal–each parent has an equal right to the custody of the child when they separate.
Like other aspects of family law, most law in this field is state rather than federal.