By Associated Press and Tim Fitzsimons

COLUMBIA, S.C. — The federal government agreed Wednesday to allow federally funded foster care agencies in South Carolina to deny services to same-sex or non-Christian couples.

The waiver issued by the U.S. Department of Health and Human Services will allow Greenville’s Miracle Hill Ministries to continue as a state-supported foster care agency.

As part of the waiver’s requirements, any family that Miracle Hill does not allow to take care of foster children must be referred to other agencies or the state Department of Social Services.

The exemption was needed because a regulation from President Barack Obama’s administration prevents publicly licensed and funded foster care agencies from serving specific religions.

South Carolina Gov. Henry McMaster asked for the waiver. He said President Donald Trump deserved credit for making sure South Carolina keeps as many groups as it can to help place foster children. The waiver request said Miracle Hill Ministries is responsible for up to 15 percent of foster care placements in the state.

“As Americans, our fundamental right to practice religion, regardless of our faith, will not be in jeopardy under this administration,” McMaster said in a statement.

Gay rights groups and non-Christian religious groups opposed the waiver, saying it would cut down on the number of people willing to be foster parents and allows public money to take away rights.

“Let’s call this decision what it is: state-sanctioned and government-funded discrimination,” said Christina Wilson Remlin, lead lawyer of Children’s Rights. The group has successfully sued South Carolina over its foster care system for placing too many children in institutions, taking children too far away from their biological families and denying treatment for the medical needs of foster children.

McMaster has said he would have asked for a waiver for a Jewish or Muslim organization because he said the issue isn’t Christianity but the constitutional protection of religion.

Jonathan Greenblatt, CEO of civil rights group Anti-Defamation League, said the group has been “fighting this prospective exemption for many months” and expressed shock that the government was granting a waiver for a federally funded adoption agency to discriminate against non-Christians.

“Allowing a taxpayer funded agency to discriminate against Jews and other minorities is outrageous and sets a dangerous precedent for our nation. This is clearly unlawful and will not hold up in court,” he said. “No child should be denied a loving foster or adoptive home simply because a prospective parent is Jewish or Muslim, gay or lesbian.”

The Human Rights Campaign, an LGBTQ advocacy group, called the exemption “unconscionable.”

“Allowing a federal contractor the ability to refuse to work with qualified prospective parents - limiting the pool of prospective parents even further - is directly counter to the best interests of the children waiting for families,” HRC State Legislative Director and Senior Counsel Cathryn Oakley said in a statement. “The federal government has a compelling interest in ensuring federal contractors are providing quality care, and in ensuring that taxpayers aren’t footing the bill for taxpayer-funded discrimination.”

FOLLOW NBC OUT ON TWITTER, FACEBOOK & INSTAGRAM