A Michigan adoption agency has reversed course and announced that it will not shut down operations if required to serve gay couples. The agency had fought a long legal battle to be able to discriminate against LGBTQ people despite the best interests of the child.

The case dates back to 2017, when two lesbian couples claimed their application to adopt a child was denied by Catholic Charities and Bethany Christian Services because of their sexual orientation. The couple were joined in the ACLU suit by a woman who spent her teenage years in the foster care system.

Bethany Christian Services had threatened to close their doors if they couldn’t discriminate, despite handling over 1000 cases for the state.

As part of a settlement in the lawsuit, Attorney General Dana Nessel nixed a four-year old law allowing adoption and foster care centers to discriminate in the name of their “religious beliefs.” Her office announced the decision in a statement calling anti-LGBTQ bias on the part of child placing agencies “illegal.”

Related: Supreme Court rejects ‘religious freedom’ case from foster agency that won’t serve gay couples

“Limiting the opportunity for a child to be adopted or fostered by a loving home not only goes against the state’s goal of finding a home for every child, it is a direct violation of the contract every child-placing agency enters into with the state,” Nessel said.

“We are disappointed with how this settlement agreement has been implemented by the state government. Nonetheless, Bethany will continue operations in Michigan, in compliance with our legal contract requirements,” Bethany Christian Services said in a statement.

Nessel tweeted over the weekend that having more adoption agencies not discriminate results in “more children adopted into loving, nurturing ‘forever’ homes. Thank you to Bethany Christian Services.”

Nine states still have laws on the books giving adoption agencies a license to discriminate against gay and lesbian couples: Alabama, Kansas, Mississippi, North Dakota, Oklahoma, South Carolina, South Dakota, Texas, and Virginia.