Last week, the Department of Health and Human Services granted a waiver to Miracle Hill, a South Carolina foster-family agency, exempting it from an Obama-era regulation requiring that federally funded agencies serve everyone, even if doing so violates the organizations’ religious principles. Reaction on the left was swift. “Let’s call this decision what it is: state-sanctioned and government-funded discrimination,” said Christina Wilson Remlin, lead lawyer for Children’s Rights. “It is despicable that this administration would authorize federally-funded state child welfare agencies to allow caring, qualified families to be turned away because they don’t pass a religious litmus test,” said ACLU lawyer Leslie Cooper.

Conservatives, by contrast, have defended the Trump administration’s decision on religious-liberty grounds. Nonprofit organizations and businesses should be able to operate according to their religious values, they argue. But the stakes here are even higher than for, say, the bakers of wedding cakes. Most foster-care agencies are faith-based. Some 440,000 kids are in foster care in the U.S.; if we shut down faith-based foster agencies, those children will have a much harder time finding homes.

Indeed, it is safe to say that most foster families in this country take in needy children because their religious beliefs tell them to do so. Foster agencies recruit these families, train them, and even certify them in some cases; they also offer emotional and logistical support for months and even years after placement. Religious foster families are among those most likely to take in children with special needs.

Unfortunately, more and more of these agencies have come under fire because they do not adhere to state, local, or federal nondiscrimination regulations. Catholic Charities in Buffalo recently ended its foster and adoption services because of a state law that would have required them to place kids with gay couples. The ACLU has sued Bethany Christian Services in Michigan to get the organization to change its policy in this area, and Philadelphia suspended its contract with Catholic Social Services for the same reason.

Closing these agencies will be like closing Catholic schools—new ones may not appear, and the ones that do may not operate with the same care and commitment as the old ones. Sharonell Fulton, a foster mother who has taken in more than 40 children with Catholic Social Services in Philadelphia asks, “What justice is there in taking stable, loving homes away from children? If the city cuts off Catholic Social Services from foster care, foster moms like me won’t have the help and support they need to care for special-needs kids.” If a foster agency like Miracle Hill—which serves 15 percent of the foster population in South Carolina—disappeared, it would have severe consequences for the state’s needy children.

The “stable, loving home” argument should be familiar to advocates of gay adoption, who for years argued that it was wrong to deny children the chance to live in a good home solely because the parents were of the same sex. This argument slowly won support across the United States. Long before gay marriage was legalized, it was becoming more common for gay couples to adopt. “I think even many rock-ribbed evangelicals could agree that most kids would be better off raised by loving gay parents than by our incredibly screwed up foster care system,” Megan McArdle wrote in the Daily Beast in 2013.

Of course, that doesn’t mean that every evangelical foster agency leader would want to be involved in placing a child with a gay couple—which is why they ran afoul of the Obama administration. But what faith-based and secular foster-family agencies have in common, or should, is an agreement that the needs of children come first. Enforcing the Obama administration dictates will result in fewer options for foster kids and fewer family placements. With the “stable, loving home” principle as a guideline, advocates for foster children should support agencies that show success in placing kids with good families—regardless of how those agencies make such decisions.

The issue is not going away. An agency from Texas recently applied for a waiver, Lynn Johnson, head of the federal Administration for Children and Families, tells me. But Washington can’t do anything about state and local ordinances that inhibit the work of religious foster agencies. The matter is likely to end up in the Supreme Court, the latest in a series of religious-liberty battles. This one could count America’s most vulnerable children among its victims.