SALT LAKE CITY -- Beckie Peirce and April Hoagland have just five more days to hold onto the baby girl they've nurtured for months.
"Knowing that that's what we've done and it's been taken away from us, is heartbreaking," Hoagland told CBS News.
The couple, legally married in Utah, planned to adopt the child. But Tuesday, according to lawyers present in the courtroom for Utah's child welfare agency, Judge Scott Johansen ordered them to give up the baby for just one reason.
"He said he's seen studies that say children do worse in homosexual homes than in heterosexual homes," Peirce said. "He told the lawyers to do their own research."
Hoagland and Pierce say the judge also ignored pleas from the baby's biological mother to grant them custody. They believe the judge, a bishop in the Mormon Church, is putting his religious beliefs before the law.
"This is all about sexual orientation, not what is best for the child," Peirce said.
"He has no other grounds but that," Hoagland added.
Utah's Division of Child and Family Services says the couple passed rigorous background checks and state law is on their side, according to director Brent Platt.
"Any legally married couple in Utah can become licensed as foster parents," Platt said. "Same-sex couples, heterosexual couples. It's very simple, very straightforward."
For Hoagland and Peirce, time is running out. And their foster daughter is their top priority.
"She's happy, she's bonded and now you're gonna take that all away from her and she has to start over," Peirce said.
The couple is appealing the judge's decision and Child and Family Services is still trying to determine if it's even legal.
CBS News wanted to speak directly to Judge Johansen but the court said he's not permitted to talk about pending cases.