Every child deserves a family, but a recent Supreme Court case could make it more difficult to find loving homes for children in foster care. On Nov. 4., the Supreme Court heard oral arguments in Fulton v. City of Philadelphia, a case on whether private, religiously affiliated foster care agencies may refuse to work with same-sex couples. These foster care agencies have become the latest bastions of resistance to LGBTQ rights, taking up conservatives’ strident calls to defy the Supreme Court’s rulings on LGBTQ equality.

There is a deeper irony to the Fulton case than a child welfare agency’s unwillingness to help children in need. The real twist is that foster care agencies used to be at the vanguard of LGBTQ rights. In the 1970s and 1980s, foster care agencies placed children in the homes of gay and lesbian couples — despite popular opposition and legal mandates to the contrary — because they believed doing so was in the best interests of the children. These acts of subversion helped create the very LGBTQ families that gave rise to the Supreme Court’s marriage equality decision.

In the 1970s, the foster system was overburdened, with ever-increasing numbers of children entering the system, but few being placed with adoptive parents or returned to their families. In response to mounting criticism, Congress enacted the Adoption Assistance and Child Welfare Act in 1980. The law provided federal funds to state agencies that were able to quickly find permanent placements for foster children. The law had its intended effect: the number of children in foster care dropped sharply, and the time children stayed in foster care also declined.

But these effects were short-lived. Both of those figures quickly rose again as families struggled with the effects of an economic recession and the crack cocaine and HIV/AIDS epidemics. Between 1986 and 1992, the number of children in foster care increased by 54 percent.

Social workers, who had been struggling to find homes for children, began placing their wards in the homes of gay and lesbian parents. These placements spurred controversy, particularly since surveys showed that the vast majority of Americans disapproved of gay and lesbian people serving as foster parents. The result was a series of legislative bans and executive orders across the country forbidding these placements. At the time, many Americans considered LGBTQ rights a threat to their values and opposed gay and lesbian adoption as harmful to children.

In 1985, after the Boston Globe reported that two young boys had been placed with a gay couple, Massachusetts Gov. Michael Dukakis announced the state would give preference to “traditional family settings.” Under his new plan, single parents and unmarried couples could foster children only if they received approval from the head of the child welfare agency. The policy did not explicitly exclude gays or lesbians, but officials in the Dukakis administration stated that such placements were “highly unlikely” given the bureaucratic hurdles the governor had created. The Massachusetts chapter of the National Association of Social Workers joined gay and lesbian parents in suing Dukakis, who ultimately revised the ban to settle the case.

A similar battle broke out in New Hampshire the same year, after a local paper reported that the state’s child welfare agency had knowingly licensed a gay man as a foster parent. The state House of Representatives quickly began debating a bill to bar “admitted homosexuals” from adopting a child or receiving foster care licenses. The proposed law also prohibited licensing anyone whose household members were gay.

Rep. Mildred Ingram, the bill’s sponsor, claimed baselessly that gay men molested children at higher rates than heterosexuals and argued that children would learn to be gay as a result of having gay and lesbian role models. The legislature enacted the prohibition, but civil servants continued to approve gays and lesbians as foster parents despite the statute. To skirt the law, they simply did not ask potential foster parents about their sexual orientation. As David Bundy, the director of the Division of Children, Youth and Families, explained when I interviewed him, “We came up with ‘don’t ask don’t tell’ way before [President Bill] Clinton.”

Social workers in other parts of the country responded similarly. In California, the Department of Social Services (CDSS) issued a policy stating it would not recommend adoptions by unmarried couples. Although this rule affected heterosexual as well as gay and lesbian couples, its aim was to prohibit same-sex couples from adopting. One couple, after suing the agency, discovered “that every document that came through the CDSS — every internal memorandum discussing the policy — had ‘Lesbian Adoption’ stamped all over it.”

Social workers complied with the letter of the law by informing courts that their department did not support the adoption petition. At the same time, they stressed that the only reason for their negative recommendation was the policy. Judges easily read between the lines and approved the adoptions.

Florida’s legislature had enacted a ban on gay and lesbian adoption in the late 1970s. In 1987, Gloria Walker, the director of the Florida Department of Health and Rehabilitative Services’ adoption service, admitted that the agency had been ignoring the statute. Walker told reporters that “she knew little about the law or why it passed the Florida Legislature” and that Florida’s adoption forms did not ask applicants about their sexual orientation. “Don’t ask, don’t tell” had become the operative principle for the Sunshine State, too.

By 2015, when the Supreme Court ruled in favor of marriage equality in Obergefell v. Hodges, it cited the fact that LGBTQ couples around the country were raising “hundreds of thousands of children.” Some were biological offspring, but many were children that LGBTQ parents had welcomed into their homes as foster parents. Two of the plaintiffs in the case, April DeBoer and Jayne Rowse, had adopted three children, one of whom was born prematurely and required around-the-clock care, and another who also had special needs. The court, in ruling on behalf of the same-sex couples, reasoned that denying LGBTQ Americans the right to marry harmed their children by denying them benefits and inflicting uncertainty simply so the state could express its disapproval.

Yet, ironically, even as LGBTQ rights have expanded dramatically, as has acceptance of LGBTQ Americans, the Supreme Court heard the Fulton case because of another policy change: Many states have privatized foster care services. To reduce public spending, federal, state and local governments now funnel taxpayer dollars to private agencies, many of which are faith-based, to provide foster care placement services for abused and neglected children. In Texas, for example, 25 percent of child placement agencies are faith-based providers that refuse to work with LGBTQ couples.

This refusal occurs despite a chronic need for foster care families. Each year, more than 250,000 children enter into foster care nationwide, a number that is growing as a result of the opioid crisis. Although approximately 50,000 children are adopted every year, about 20,000 age out of foster care without ever having found a permanent home.

LGBTQ couples are seven times more likely to serve as foster parents than their opposite-sex counterparts, and studies show that children fare just as well with same-sex parents as with opposite-sex ones. Despite the crucial service that LGBTQ Americans provide, 10 states permit foster agencies to discriminate against same-sex couples based on their religious beliefs. Only eight states affirmatively protect LGBT parents from discrimination in foster care.

At oral argument, the justices seemed to be divided on whether faith-based child welfare agencies should be able to claim religious exemptions to anti-discrimination laws. They repeatedly asked the attorneys how they should balance the rights of religious agencies and prospective parents. But the Fulton case is about more than protecting the right of LGBTQ adults. Should the Supreme Court uphold the agency’s refusal to work with gay and lesbian parents, the result will be to harm the very children that the state is charged with protecting.