The U.S. Supreme Court ruled on Thursday in favor of Native American rights in adoption and child-custody proceedings.

The 7-2 decision turned aside prospective parents from Fort Worth hoping to adopt a child. They were challenging the 1978 Indian Child Welfare Act that prioritizes the placement of Native American children with Native families or tribes.

Jennifer and Chad Brackeen, along with other families, challenged the law after adopting a Native American boy, known as A.L.M. in court records, in 2016.

The boy was born to a Navajo mother and a Cherokee father, and both tribes agreed to let the couple keep him.

In 2018, U.S. District Court Judge Reed O’Connor ruled the law was unconstitutional and allowed A.L.M. to stay with the Brackeens.

That same year, A.L.M.’s mother gave birth to a girl, and she was sent into the foster care system. The Brackeens wanted to adopt her, uniting her with her brother.

The Navajo wanted to place the girl with her great-aunt, who lives on a reservation.

A state judge determined that the Brackeens would share custody with the great-aunt.

Their case against five Texas tribes landed in the Supreme Court this term.

Justice Amy Coney Barrett wrote the majority opinion. Justices Clarence Thomas and Samuel A. Alito Jr. dissented.

“The issues are complicated,” Barrett wrote. “But the bottom line is that we reject all of petitioners’ challenges to the statute, some on the merits and others for lack of standing.”

Justice Ketanji Brown Jackson wrote that Congress has the right to regulate adoption on reservations.

“Congress said things like there’s no resource that is more vital to the continued existence and integrity of Indian tribes than their children,” she wrote. “They constantly cast regulations regarding children, Indian children, as a matter of tribal integrity, self-governance, existence.”