The Third Court of Appeals in Austin said the state failed to show the youngsters were in any immediate danger, the only grounds in Texas law for taking children from their parents without court action.
It was not clear whether the children - now scattered in foster homes across the state - might soon be returned to their parents. The ruling gave a lower-court judge 10 days to release the youngsters from state custody, but the state could appeal to the Texas Supreme Court and block that from happening.
"Unless this ruling gets overturned on appeal, it looks like Texas authorities will be required to return most if not all of the children back to the compound and to their mothers sooner rather than later," said CBS News legal analyst Andrew Cohen. "And at that point I imagine there will be some sort of major investigation into how law enforcement officials could have blundered so massively, if indeed they have."
The decision in one of the biggest child-custody cases in U.S. history was a humiliating defeat for the state Child Protective Services agency. It was hailed as vindication by members of the Fundamentalist Church of Jesus Christ of Latter Day Saints, who claimed they were being persecuted for their religious beliefs.
"It's a great day for Texas justice. This was the right decision," said Julie Balovich, a Legal Aid attorney for some of the parents. She was joined by several smiling mothers who declined to comment at a news conference outside the courthouse in San Angelo.
Some court-appointed attorneys for the children are in a holding pattern, reports CBS News correspondent Hari Sreenivasan. Susan Hayes, who represents a two-year-old, says she is not worried about abuse if the child is returned.
"I have not seen anything about my client, and there are a lot of ad litems that have seen nothing about their particular clients and their families," she said.
Every child at the Yearning For Zion Ranch in Eldorado was taken into state custody more than six weeks ago after someone called a hot line claiming to be a pregnant, abused teenage wife. The girl has not been found and authorities are investigating whether the calls were a hoax.
Child-protection officials argued that five girls at the ranch had become pregnant at 15 and 16 and that the sect pushed underage girls into marriage and sex with older men and groomed boys to enter into such unions when they reached adulthood.
"What the court didn't address is there are still, without any question, young girls out there who are pregnant, and that's part of the culture," Texas attorney Guy Choate told CBS News anchor Katie Couric.
But the appeals court said the state was not justified in sweeping up all the children and taking them away on an emergency basis without going to court first.
"Even if one views the FLDS belief system as creating a danger of sexual abuse by grooming boys to be perpetrators of sexual abuse and raising girls to be victims of sexual abuse ... there is no evidence that this danger is 'immediate' or 'urgent'," the court said.
"Evidence that children raised in this particular environment may someday have their physical health and safety threatened is not evidence that the danger is imminent enough to warrant invoking the extreme measure of immediate removal."
The court said the state failed to show that any more than five of the teenage girls were being sexually abused, and offered no evidence of sexual or physical abuse against the other children. Half the youngsters taken from the ranch were under 5. Only a few dozen are teenage girls.
The court also said the state was wrong to consider the entire ranch as a single household and to seize all the children on the grounds that some parents in the home might be abusers.
CPS spokesman Patrick Crimmins said department attorneys had not decided whether to appeal. "We are trying to assess the impact that this may have on our case," he said.
CPS's umbrella agency, the Department of Family and Protective Services, issued a statement defending the raid, saying it removed the children "after finding a pervasive pattern of sexual abuse that puts every child at the ranch at risk."
"Child Protective Services has one duty - to protect children. When we see evidence that children have been sexually abused and remain at risk of further abuse, we will act," the department said.
FLDS spokesman Rod Parker said sect members feel vindicated. "They're very thrilled. They're looking forward to seeing the children returned," he said.
The decision technically applies to only 38 of the roughly 200 parents who challenged the seizure. But Balovich said she expected attorneys for all the other parents to seek to join the ruling.
Balovich said the court "has stood up for the legal rights of these families and given these mothers hope that their families will be brought back together."
Of the 31 people the state initially said were underage mothers, 15 have been reclassified as adults, and one is 27.
Five judges in San Angelo, about 40 miles north of Eldorado, have been holding hearings on what the parents must do to regain custody. Those hearings, which began Monday, were suspended after the ruling Thursday.
"The appeals court ruled that the state didn't prove that the children were in immediate danger when they were taken from the compound. But that's a different standard from the one the trial courts in San Angelo now are using to come up with individual custody plans for many of the children. So this is still a very fluid situation," Cohen said.
"The appellate court now has ordered the trial court to 'vacate' its order granting 'sole' conservatorship of children to the Child Welfare Department. So the ball is now in the hands of the judge or judges in San Angelo, who either can comply with the order or try to weasel around it," Cohen said. "There is a middle path here - the idea that the trial court could vacate the 'sole' part of the conservatorship but still allow the department to maintain some level of oversight over the welfare of the kids."
The custody case has been chaotic from the beginning. During the first round of hearings, held two weeks after the April 3 raid, hundreds of lawyers crammed into a courtroom and nearby auditorium, queuing up to voice objections or ask questions on behalf of the mothers who were there in their trademark prairie dresses and braided hair.
CPS has struggled for weeks to establish the identities of the children and sort out their tangled family relationships. The youngsters are in foster homes all over the sprawling state, with some brothers or sisters separated by as much as 600 miles.