SAN ANGELO, Texas - In a ruling that could torpedo the case against the West Texas polygamist sect, a state appeals court Thursday said authorities had no right to seize more than 440 children in a raid on the splinter group's compound last month.

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 when the children — now scattered in foster homes across the state — might be returned to their parents. The ruling gave a lower-court judge 10 days to release the youngsters from custody, but the state could appeal to the Texas Supreme Court and block that.

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.

Sect elder Willie Jessop said the parents were elated, but added: "There will be no celebrations until some little children are getting hugs from their parents." He said his faith in the legal system will be restored "when I see the schoolyard full of children."

Every child at the Yearning For Zion Ranch in Eldorado was taken into 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 grew up.

But the appeals court said the state acted too hastily 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 5 or younger. 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.

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 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.