"It's not fair and it's not right and it just hurts me really badly," said April Hoagland, sitting next to her wife, Beckie Peirce. A judge ordered that their foster child be removed from their Carbon County, Utah, home and placed with a heterosexual couple instead. (Reuters)

A Utah judge ordered a lesbian couple this week to give up their foster daughter to heterosexual parents, highlighting a harsh reality for same-sex couples: Although they can now marry legally in the United States, many still face huge obstacles to becoming parents.

That fact was on display when Judge Scott Johansen, a juvenile-court justice in eastern Utah, ordered a 9-month-old girl removed from the home of Beckie Peirce and April Hoagland. Although the state’s child-welfare office and the birth mother had approved the child’s placement in the couple’s home, Johansen said Tuesday that she would be better off in a family led by heterosexual parents.

“Today Judge Scott Johansen ordered our foster child be moved due to our sexual orientation!” Peirce wrote on Facebook that afternoon. “How is this ok?”

The story caught fire nationally, provoking outrage from gay rights supporters who called Johansen’s order backward and unconstitutional. Democratic presidential candidate Hillary Rodham Clinton tweeted in response Wednesday that “being a good parent has nothing to do with sexual orientation — thousands of families prove that.” Utah Gov. Gary R. Herbert (R) pronounced himself “puzzled” by the ruling and concerned about judicial “activism.”

Longtime gay rights advocates said the decision, while upsetting, was not altogether surprising: Although the Supreme Court affirmed the right to same-sex marriage nationally in June, many states have yet to incorporate the ruling into their policies governing parenting rights.

A Utah judge ordered that a foster child be removed from the home of April Hoagland and Beckie Peirce, who are married. The judge said the 9-month-old girl would be better off in a family led by heterosexual parents. (Steve Griffin/Salt Lake Tribune via AP)

Same-sex couples often choose foster care and adoption as a route to parenthood, but both systems have sparked passionate debates over civil rights and discrimination because people disagree about what is best for children. In addition to sexual orientation, fights have erupted over black children being placed with white parents and the appropriateness of single-parent homes.

Only seven states explicitly bar discrimination against gay parents in foster care, said Emily Hecht-McGowan, director of public policy for the Family Equality Council, which advocates for the rights of gay and transgender parents. Mississippi still has a law on the books barring same-sex couples — including those who are legally married — from adopting children. The law is being challenged in court.

In Florida, litigation is pending over a decision by the state’s health department to bar the non-birth parent in a same-sex couple from being included on a child’s birth certificate, unlike heterosexual couples. Several states recently enacted protections allowing child-placement agencies to refuse placements for religious reasons. And questions remain generally about whether “all the rights of parentage granted to different-sex couples will flow seamlessly to same-sex couples,” Hecht-McGowan said.

“My guess is that we’ll be addressing those issues in the courts for many years to come,” she said.

In Utah, she said, state laws governing foster care give preference to heterosexual married couples. Earlier this year, Utah adopted an anti-discrimination law that won praise from both gay rights groups and religious liberties advocates. But it does not bar discrimination in public accommodations — the category into which foster care and adoption would likely fall, said Robin Maril, senior legislative counsel for the Human Rights Campaign, a national gay rights organization.

Still, many legal experts said Johansen’s order is unlikely to withstand a legal challenge. The Supreme Court ruling affirming the right to same-sex marriage essentially established legal parity between same-sex and heterosexual married couples, they said, leaving Johansen no legal rationale for favoring one over the other.

Maril said Peirce and Hoagland would have a strong case if they invoked the 14th Amendment’s equal-protection clause, which requires state laws to be applied equally to all people.

“We have no reason to believe that if they brought an equal-protection claim that it would not work,” she said.

On Thursday, Peirce and Hoagland did not respond to repeated requests for comment. The judge’s order was not available and will not be made public by the court because it involves a juvenile. However, a spokeswoman for the Utah courts confirmed the basic facts of the decision, and the state’s Division of Child and Family Services confirmed aspects of it.

Brent Platt, the agency’s director, said the 9-month-old girl was placed with Peirce and Hoagland three months ago. The couple met the agency’s rigorous vetting process, he said, and was moving toward adopting the girl with the blessing of her birth mother.

On Tuesday, Platt said the agency was stunned to receive an order telling it to remove the child from the Peirce-Hoagland home within seven days and to place her with a heterosexual couple.

The situation was “very unique,” Platt said, because the agency has placed children in many gay households since same-sex marriage became legal in Utah two years ago. Never before, he said, has a judge cited the parents’ sexual orientation as a reason to remove a child.

Platt said the agency is looking for a heterosexual couple to care for the girl, but it has also asked for a stay of the decision.

“We don’t take placements lightly,” he said, adding that the agency takes pains to find a loving and positive environment for each child. “And I’m confident that’s what the team did in this situation.”

In interviews with local reporters, Peirce and Hoagland said the judge explained his decision by citing “research” suggesting that children do better in homes led by heterosexual parents. However, he did not provide that research when asked for it, they said.

Peirce, 34, and Hoagland, 38, from rural Carbon County, were legally married in October 2014 and were licensed as foster parents this year, according to the Salt Lake Tribune. They are also raising Peirce’s two children, 12 and 14, the newspaper reported.

The couple expressed grief at the idea of giving up a girl who they said had been thriving in her new home, and they pledged to appeal.

The ruling is “heartbreaking,” Hoagland told KUTV, the CBS affiliate in Salt Lake City. “We’ve been told to care for this child like a mother would, and I am her mother, that’s who she knows, and she’s just going to be taken away in seven days. . . . It’s not fair and it’s not right, and it just hurts me really badly because I’ve done nothing wrong.”

This is not the first time one of Johansen’s decisions has made headlines. In 1995, at the courthouse in Price, Utah, where he served, he slapped the 16-year-old son of a friend who thought the teenager was stealing, according to media reports. Johansen expressed regret for the incident, and he was reprimanded by a judicial conduct commission for “demeaning the judicial office.”

In 2012, Johansen made an unusual decision while pondering the fate of a teenager facing assault charges for cutting off most of a toddler’s hair. He ordered the child’s mother to cut off the teen’s ponytail in the courtroom in exchange for a lighter sentence, according to Salt Lake City’s Deseret News.

Also in 2012, the Tribune took Johansen to task for imposing a harsh sentence on a boy who had been on probation for stealing a pack of gum. He ordered the boy sent back to jail because he had violated his probation by getting poor grades on his report card, the editorial said.

Alice Crites and Justin Wm. Moyer contributed to this report.