A Catholic charity in upstate New York is terminating their long-running foster and adoptive services to avoid granting an adoptive foster-care license to a same-sex married couple.

The Catholic Charity of Buffalo announced Thursday they are “phasing out” their century-old adoption program instead of approving the couple, claiming they cannot simultaneously comply with state regulations and conform to church doctrine.

“We were in conflict,” Rose Caldwell, the charity’s director of communication and public relations, told The Daily Beast. “We could not discriminate against the couple but we also had to uphold church laws.”

New York state law requires contracting organizations—like a charity—to allow same-sex couples to adopt or to raise foster children. That law, however, goes against the Roman Catholic Church’s official position that marriage is a union only between a woman and a man.

And while Pope Francis has publicly accepted the LGBT community multiple times, the charity argues that teaching does not extend to adoption.

“Marriage is only between man and a woman and it is to the advantage of the child to have both a father and a mother,” said Sister Mary McCarrick, diocesan director of the charity, in a press conference Wednesday.

According to charity officials, this is the first same-sex couple to seek foster certification through the Catholic Charity of Buffalo. It was not until the final stage of their application approval process that the couple was asked about their sexual orientation.

Deferring the issue to their Catholic Diocese of Buffalo, the charity had to inform the couple they could not seek foster certification through the Catholic church and was provided with other options.

“They were in shock as you can imagine,” said Caldwell. “There is nothing else to indicate about it.”

The Catholic Diocese of Buffalo declined to provide a comment for this story.

The charity’s foster and adoption program is currently responsible for 55 certified foster homes, averaging five adoptions per year. The adoption service was one of the top services offered by the charity since it was founded nearly a century ago.

“It is with deep sadness we acknowledge that the legacy of the high quality, exceptional services which our staff provides to children and families through foster care and adoption will be lost,” said Dennis C. Walczyk, Catholic Charities' chief executive officer, in a Wednesday statement.

The Catholic Charities of Buffalo’s adoption program has a contract with the Erie County Department of Social Services that is now set to expire in March 2019.

"With respect to community partner agencies, we have no comment on individual business decisions. As always we continue to advocate for all children to grow up in the safest, most loving and most nurturing environment possible, allowing them to reach their full potential,” Amanda Kelkenberg, CEO of Child Care Resource Network, said in a statement Wednesday.

Despite the abrupt decision to phase out the program, the Catholic Charity of Buffalo said they are working with county and state officials to support a smooth transition.

“We are working with families and state officials to ensure that no child will be moved from their currently placement,” said Caldwell.

This is the fourth Catholic charity—the others in Boston, Illinois, and San Francisco—to terminate their adoption program in order to comply with both state and religious law.