The American Civil Liberties Union has filed a motion in federal court asking to intervene in a lawsuit brought by Catholic Social Services against the city of Philadelphia for its policy barring child placement agencies from discrimination against same-sex couples.

CSS sued the city after it stopped referring foster children to the CSS because of its refusal to license qualified same-sex couples as foster parents or allow them to adopt children in the agency’s care. In its lawsuit, CSS claims that the policy violates their religious freedom, as their religious beliefs dictate that marriage is reserved for only those unions between one man and one woman.

The ACLU’s motion to intervene was brought on behalf of the Support Center for Child Advocates, a nonprofit providing legal representation and services to children in the foster care system, and Philadelphia Family Pride. If a judge grants their motion, the ACLU will be able to argue, on behalf of the two organizations, how overturning the city’s policy will harm LGBTQ families and children in the foster care system waiting to be placed in loving homes.

“The heart of this case is what is in the best interests of children,” Reggie Shuford, the executive director of the ACLU of Pennsylvania, said in a statement. “Loving, supportive, same-sex couples are willing to open their homes to kids in need, but CSS’s policy gives them one less avenue to make that happen. It would be a tremendous loss for our children if agencies were permitted to turn away good families based on failure to meet religious criteria.”

“Children in foster care in Philadelphia need every possible family that is ready, willing, and able to care for them,” Frank Cervone, the executive director of the Support Center for Child Advocates, said in a statement. “The Support Center for Child Advocates is entering the case to advocate for the best interests of all of Philadelphia’s children. We are in this for the kids. They need a voice in this dispute.”

CSS previously asked the court for an injunction that would order the city to continue referring kids to CSS while litigation proceeds. That hearing, on whether to grant the injunction, is scheduled for Monday, June 18.

In recent months, both Kansas and Oklahoma have passed laws that allow child placement agencies to discriminate against prospective parents for a host of reasons, including marital status and sexual orientation. LGBTQ advocates have railed against such policies, arguing that they prioritize people’s anti-gay religious beliefs over what’s best for children in the foster care system.

“When governments contract with private agencies to provide public child welfare services and pay them taxpayer dollars to do it, they may not permit them to turn away qualified families based on religious objections to those families,” Leslie Cooper of the ACLU’s LGBT and HIV Project said in a statement. “That would violate the constitution.”