LANSING, Mich. (AP) — Religious-based adoption agencies that contract with the state of Michigan will be allowed to refuse to place children in LGBT homes under a preliminary injunction issued by a federal judge Thursday.

District Judge Robert Jonker in Grand Rapids blocked Democratic state Attorney General Dana Nessel, Michigan’s first openly gay statewide officeholder, from barring the faith-based agencies from excluding LGBT couples from services.

He said her action conflicted with state law, existing contracts and established practice. Nessel had, through a legal settlement between same-sex couples and the state Department of Health and Human Services, reversed the state’s stance earlier this year.

Michigan, like most states, contracts with private agencies to place children from troubled homes with new families.

Jonker, in issuing a preliminary injunction, said Lansing-based St. Vincent Catholic Charities’ longstanding practice of adhering to its religious beliefs and referring same-sex and unmarried couples to other agencies is not discriminatory.

Detroit Free Press via Getty Images Democratic state Attorney General Dana Nessel is Michigan’s first openly gay statewide officeholder.

Wanting to cancel the contract “strongly suggests the State’s real goal is not to promote non-discriminatory child placements, but to stamp out St. Vincent’s religious belief and replace it with the State’s own. ... It would disrupt a carefully balanced and established practice that ensures non-discrimination in child placements while still accommodating traditional Catholic religious beliefs on marriage,” he wrote.

A spokeswoman for Nessel said her office was reviewing the decision to determine next steps.

Nessel in March announced an agreement with the American Civil Liberties Union to resolve a 2017 lawsuit filed by two lesbian couples. The settlement said a 2015 Republican-backed law that lets child-placement agencies not provide any services that conflict with their sincerely held religious beliefs does not apply if they are under contract with the state.

“Today’s ruling requires the state to put the individual religious beliefs of foster care agencies ahead of the welfare of children,” said Jay Kaplan, staff attorney for the ACLU of Michigan’s LGBT Project. “This will not facilitate foster and adoptive placements for children in need. Instead, it will allow agencies to turn away same-sex foster parents who are able to provide supportive and loving homes for these children.”

In April, the Becket Fund for Religious Liberty challenged Nessel’s deal, suing on behalf of St. Vincent, two adoptive parents and a former foster child who was adopted. The complaint alleges violations of the plaintiffs’ First Amendment rights and the federal Religious Freedom Restoration Act — claims on which the plaintiffs will likely prevail, according to the judge.

Jonker, an appointee of former President George W. Bush, also declined to dismiss Nessel from the suit, saying she “targeted” St. Vincent. He said she is at the “very heart” of the case after she made past statements referring to proponents of the 2015 law as “hate-mongers” and calling the measure indefensible during her 2018 campaign.

The decision was cheered by one of the adoptive parents, Melissa Buck of Holt, near Lansing. St. Vincent helped her and her husband, Chad, adopt five special needs children who were in the state’s foster care system.

“St. Vincent brought our family together, and I’m happy to know they can keep doing their great work helping children find homes,” she said.