Philadelphia can require its foster care agencies to adhere to its nondiscrimination polices, a federal judge said Friday in a decision that could have national repercussions.

U.S. District Court Judge Petrese B. Tucker found that the city did not violate the religious liberties of Catholic Social Services (CSS) when it suspended its contract with the agency for foster-care services after discovering that the agency would not work with same-sex couples.

The Department of Human Services had a legitimate interest in ensuring "that the pool of foster parents and resource caregivers is as diverse and broad as the children in need of foster parents," Tucker wrote in a decision Friday denying CSS's request for a temporary restraining order to resume its work for the city.

The city welcomed the news.

"As the court found, the city has a legitimate interest in ensuring that when we employ contractors to provide governmental services, that those services are accessible to all Philadelphians who are qualified for the services," spokeswoman Deana Gamble said in a statement. "Regrettably, by refusing to certify same-sex couples, CSS is ruling out qualified families who are willing to provide care for children in need, who can be certified, and who have roots in this community. "

DHS has said that it will not remove children already in CSS-certified families, and has and will continue to make exceptions in some cases, including placing a child with a sibling already in a CSS home.

Attorneys for CSS, who filed the lawsuit along with three foster parents, said they would appeal.

"Foster children deserve loving homes, and foster parents like Ms. Fulton and Mrs. Paul have been waiting with open arms to welcome them," said Lori Windham, senior counsel at Becket Law. "But the city has put politics above the children, and today the court allowed the city's discriminatory actions to continue — a decision we will immediately appeal." Cecilia Paul, a foster parent through CSS for 46 years, and Sharonell Fulton, another foster parent, were among those filing the suit and testified on behalf of CSS in last month's hearing before Tucker.

The case stemmed from an instance last year in which a same-sex couple interested in fostering were turned away from Bethany Christian Services after the agency learned they were gay. Their story appeared in March in the Inquirer and Daily News. The story also noted that  Bethany and CSS had policies preventing staff from working with same-sex couples.

At the time, the city said it was unaware of the discriminatory policies, and stopped foster-care referrals to both agencies following the report. Bethany has since changed its policy and will resume work with the city, according to court testimony.

CSS sued, arguing over three days of testimony that requiring the organization to abandon its religious beliefs in order to care for kids infringed on its religious freedoms, and that the suspension put children in need of good homes at risk. Staff from CSS testified that the organization had about 30 certified homes going unused.

The city now has 29 foster care agencies it contracts with to certify that homes and families are safe for the 6,000 kids in DHS custody. Catholic Social Services was reimbursed $1.7 million last year for placing 266 children, representing 1.9 percent of the amount the city paid in foster care services. (Bethany was reimbursed $1.3 million for operating foster homes for 170 children.)

In testimony, James Amato, who heads CSS's foster care program, said conducting a home study to certify a family "is essentially a validation of the relationships in that home." He said that because a same-sex couple's relationship "is not one that is acceptable in terms of church teaching," to certify such a couple would violate the organization's religious beliefs.

Amato said in court that if the contract was not renewed, the foster care program would be forced to shutter and lay off its staff.

CSS has several other contracts with the city that remain unaffected, including a contract with DHS as one of 10 community umbrella organizations that work with children and families already in the foster-care system. CSS has additional contracts with the Office of Homeless Services, the Department of Public Health, Planning and Development, and the Office of Behavioral Health and Intellectual disAbility Services, that are unaffected by the ruling.

In her decision, Tucker agreed with the city's assertion that CSS's policy against working with same-sex couples violated Philadelphia's Fair Practices Ordinance, which forbids city contractors from discriminating on the base of sexuality.

She noted that testimony indicated that CSS could be in violation of another aspect of the ordinance, one unaffiliated with this case. CSS's Amato had testified that his organization requires a letter from a clergy member from all interested foster parents. The denomination of the sender does not matter but Tucker called the condition problematic. "This evidence is disconcerting to the court because it raises serious constitutional as well as contractual questions," Tucker wrote.

The ACLU of Pennsylvania, which filed a brief in support of the city, celebrated the decision as the first of its kind in the nation and said it could have a bearing on similar cases pending in Michigan and Texas.

"When faith-based agencies choose to receive taxpayer dollars to provide public child-welfare services, their religious beliefs cannot trump the best interests of the children in their care," said Leslie Cooper, deputy director of the ACLU's LGBT and HIV Project. "The court saw it was not only permissible for the City of Philadelphia to prohibit discrimination by its contract agencies, but that allowing the use of religious screening requirements in the public child welfare system would likely violate the Constitution."