Philadelphia city government can require that contractor Catholic Social Services does not discriminate against same-sex couples in its foster care program, a federal appeals court ruled Monday.

The 3rd U.S. Circuit Court of Appeals upheld the city after it stopped placing children with the Archdiocese of Philadelphia’s agency because it would not permit same-sex couples to serve as foster parents.

The court ruled the city did not target the agency because of its religious beliefs but acted only to enforce its own nondiscrimination policy in the face of what seemed to be a clear violation.

“The city stands on firm ground in requiring its contractors to abide by its non-discrimination policies when administering public services,” wrote Circuit Court Judge Thomas Ambro for the three-judge panel.

Catholic Social Services sought an order requiring Philadelphia to renew its contract as a foster care agency and had argued the city’s actions violated the U.S. Constitution’s guarantee of the right to freely practice one’s religion.

The Washington, D.C.-based law firm that represents Catholic Social Services in the matter said the city’s policy has prevented dozens of families who want to take in children from doing so for nearly a year. Asked about a possible appeal, a spokesman said legal options were being reviewed.

“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,” said Lori Windham, a lawyer for Catholic Social Services.

Philadelphia Human Services commissioner Cynthia Figeroa said the decision will help the city best serve children under its care.

“We want all individuals who are able to provide safe, loving and welcoming homes to consider fostering,” Figeroa said.

The Catholic Social Services policy came to the city’s attention in March 2018, when a reporter with The Philadelphia Inquirer asked about it, Ambro wrote.

He said Catholic Social Services won’t certify same-sex married couples because of religious principles, nor will it allow unmarried cohabitating couples to foster children under its program.

It only allows married or single people in the program, and considers same-sex couples to be unmarried.

The agency disclosed at a hearing in the case that it also required prospective foster parents to obtain a “pastoral letter” from a religious figure of any faith or denomination that said the parents were actively religious, attending services and the like.

After the city objected, arguing that it violated their contract and the U.S. Constitution’s provision against establishment of religion, the agency said it would no longer require the pastoral letter.

Philadelphia instituted a “placement hold” that has kept Catholic Social Services from placing additional children with foster parents.

The Inquirer reported that Catholic Social Services placed about 260 kids in 2017. A city spokesman said Human Services has contracts with 29 agencies to license foster homes for just over 5,000 children.