CHILD CUSTODY battles can be some of the most emotionally wrenching legal disputes any judge must sort through. Add the United States’ history of discriminating against Native Americans, and you get the case of Baby Veronica, a little girl caught between her biological Cherokee father and her would-be adoptive parents. After years of contention, the Supreme Court handed the adoptive parents a victory last week. It was the right call, but not the end of the story.

Before Baby Veronica was born, her biological father, Dusten Brown, gave up his parental rights in a text message to the girl’s biological mother, and he did not provide financial support to mother or child. The mother gave the baby up for adoption, finding a willing couple in South Carolina, Matt and Melanie Capobianco. The Capobiancos supported Veronica’s mother — they even attended the birth in Oklahoma — before taking the child home. Seems simple enough.

But because Mr. Brown is a registered member of the Cherokee Nation, he claims special protections under a federal law designed to combat the breakup of Native American families. Before the 1978 Indian Child Welfare Act, state social workers too often removed Native American children from their homes without cause, placing them in non-Indian households. So Congress barred removal of Native children unless, among other things, “the continued custody of the child by the parent or Indian custodian is likely to result in serious emotional or physical damage to the child.”

After receiving notice of the adoption, Mr. Brown decided to press for custody of Veronica. Citing federal law, two South Carolina courts sided with him, even though it was almost certainly in the girl’s best interests to stay with the only parents she had ever known. Consequently, the state removed Veronica from the Capobiancos’ home when she was 27 months old, giving the girl to her biological father, with whom she has lived since the end of 2011.

The Supreme Court majority ruled that federal law did not demand this result. The law, the justices pointed out, protects the “continued” custody of Native American children by their biological parents. Since Mr. Brown did not have physical or legal custody of any kind at any point before 2011 — and, in fact, had renounced his rights — approving the Capobiancos’ adoption would not have broken up any preexisting Native American family. Reading the law otherwise, Justice Samuel A. Alito Jr. noted, would mean that “a biological Indian father could abandon his child in utero and refuse any support for the birth mother — perhaps contributing to the mother’s decision to put the child up for adoption — and then could play his [Indian Child Welfare Act] trump card at the eleventh hour to override the mother’s decision and the child’s best interests.”

This is not an easy situation. Both Mr. Brown and the Capobiancos appear to care deeply for Veronica. In addition, Justice Stephen G. Breyer noted in a concurrence, the court had to ensure that it was not dismissive of the rights of Native American fathers who don’t have technical custody of their children but who are more engaged in their lives than Mr. Brown had been in his daughter’s.

Now Veronica’s case is back in South Carolina courts, which will have to determine what makes the most sense for a child who has already had to switch families once. They should have put her best interests first from the beginning.