A federal appeals court has ruled in favor of the city of Philadelphia after it was sued for requiring that faith-based foster and adoption care agencies place children with same-sex parents.

The 3rd U.S. Circuit Court of Appeals ruled 3-0 on Monday against Catholic Social Services of the Archdiocese of Philadelphia and three individuals who served as foster parents with CSS.

The agency was one of two faith-based agencies that worked with the city to place foster children who had policies prohibiting the placement of children with same-sex couples.

But last year, the city government moved to force faith-based adoption and foster agencies with limitations on same-sex placement to change their policies to comply with the city’s nondiscrimination laws protecting on the basis of sexual orientation and gender identity or halt their adoption and foster programs.

While the other agency, Bethany Christian Services of Greater Delaware Valley, ultimately changed its policy to be able to continue working with the city, CSS refused to alter its policy, believing that it goes against Catholic teachings.

As a result, Philadelphia no longer works with CSS despite the fact that the city government put out an “urgent call” last year because of a shortage of foster parents.

The lead plaintiff in the lawsuit is Sharonell Fulton, who has fostered more than 40 children in 26 years with CSS. Fulton argues that the city’s decision effectively took “loving homes” away from children that needed them.

The lawsuit makes the argument that the city’s policy violates the First Amendment protection on freedom of religion.

“As a single mom and woman of color, I’ve known a thing or two about discrimination over the years,” Fulton argued in an op-ed. “But I have never known vindictive religious discrimination like this, and I feel the fresh sting of bias watching my faith publicly derided by Philadelphia’s politicians.”

The case was appealed to the Third Circuit after a federal district judge ruled in favor of the city last year.

In its ruling, the Third Circuit argued that the First Amendment “does not prohibit government regulation of religiously motivated conduct so long as that regulation is not a veiled attempt to suppress disfavored religious beliefs.”

“And while CSS may assert that the City’s actions were not driven by a sincere commitment to equality but rather by anti-religious and anti-Catholic bias (and is of course able to introduce additional evidence as this case proceeds), the current record does not show religious persecution or bias,” the court rules. “Instead it shows so far the City’s good faith in its effort to enforce its laws against discrimination.”

Represented by the religious freedom law firm Becket, the plaintiffs argued that city officials showed an anti-religious bias during a meeting between city leaders and leaders from CSS.

Department of Human Services Commissioner Cynthia Figueroa was accused of telling CSS leaders that “the times have changed [and] that they needed to be listening to Pope Francis rather than [conservative] Archbishop [Joseph] Chaput.”

Figueroa denied mentioning anyone other than Pope Francis.

Becket attorney Lori Windham had previously argued that no LGBT person has ever approached Catholic Social Services about completing a foster care certification process. She argued the discrimination problem that the city is trying to fix is “hypothetical.”

“This ruling is devastating to the hundreds of foster children who have been waiting for a family and to the dozens of parents working with Catholic Social Services who have been waiting to foster a child,” Windham said in a statement. “We’re disappointed that the court decided to let the city place politics above the needs of kids and the rights of parents, but we will continue this fight.”

According to Becket, there are 6,000 foster children in Philadelphia and there are dozens of families licensed to foster through CSS. But because of the city policy, the beds in the dozens of these foster parents’ homes have been empty for nearly a year.

The court’s decision was praised by Philadelphia Democrat Mayor Jim Kenney and other city officials. Kenney claimed in a statement that the city’s policy actually “safeguards religious liberties.”

“I am grateful for the Court’s careful analysis of the case and its thoughtful decision,” Kenney said in a statement.

“Our policy ensures that same-sex couples do not face discrimination as they seek to offer loving homes to Philadelphia children in need of foster care. At the same time, the policy safeguards religious liberties. We are proud that Philadelphia is a welcoming, inclusive city that values the diversity of its residents. This policy is the embodiment of those values, and we are pleased that the court has now upheld it.”

Faith-based foster and adoption agencies have had to close down in other parts of the United States do to similar local and state government policies forcing agencies to work with same-sex couples in order to comply with nondiscrimination protections.

Most recently, Michigan indicated that it will force faith-based adoption agencies who contract with the state to place children with same-sex couples after a legal settlement.

A summary of the agreement states that First Amendment legal protections for faith-based adoption or foster care agencies “no longer applies” when those agencies accept a referral from the Michigan Department of Health and Human Services.