Michigan is illegally allowing faith-based organizations to reject same-sex couples who want to adopt children or become foster parents, the American Civil Liberties Union (ACLU) said Wednesday in a lawsuit challenging the practice.

The state pays groups such as Catholic Charities and Bethany Christian Services to place children from troubled families with new families. The ACLU said Michigan is violating the U.S. Constitution by allowing the groups to use a religious test to carry out public services.

Allowing agencies to discriminate could be the difference "between a child finding a permanent loving home or staying in the system," ACLU attorney Jay Kaplan said.

Related: Arizona Supreme Court Says Gays Get Equal Parental Rights

Republican Gov. Rick Snyder signed a law in 2015 that says child-placement agencies aren't required to provide services that conflict with their beliefs. It was signed, however, before the U.S. Supreme Court legalized gay marriage.

The Department of Health and Human Services declined to comment on the lawsuit, which was filed in Detroit federal court, and instead referred to the law.

The Morning Rundown Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The plaintiffs in the ACLU lawsuit include Dana and Kristy Dumont, who said they were turned down by two faith-based agencies in the Lansing area.

When Dana and Kristy contacted a state-contracted agency to start the adoption process, they were told by an agency representative that “the agency does not work with same-sex couples,” according to an ACLU statement. The couple made another attempt with a different agency and got the same response.

"We have a lot to offer a child. We have a lot of love to give," Dana, a state employee who responded to state emails encouraging adoption, said.

Related: Commentary: Why Good People Reject Bad Religion

Kaplan said the lawsuit was filed after Michigan Attorney General Bill Schuette's office declined to speak to the ACLU about possible discrimination. He said he wants to be clear, however, that the ACLU is not challenging the private agencies, but rather suing Michigan for allowing state-contracted organizations to sponsor discrimination against gay families.

“The idea that our state would be funding organizations who keep children in that situation rather than loving, stable, supportive families who just happen to have two parents of the same sex is harmful and offensive,” Stephanie White, executive director of LGBTQ advocacy organization Equality Michigan, told NBC News.

“These are not just private institutions operating under private funds under their own private rules. These are institutions that have been given a government contract [which uses] our public tax dollars to support this discrimination,” she added. “The fact that I’m being asked to fund, through my own tax dollars, my own discrimination is outrageous.”

The Michigan Catholic Conference, the public policy arm of the church in Michigan, criticized the lawsuit as "mean-spirited, divisive and intolerant."

"It is imperative for the state law to be defended from yet another egregious attack on religious faith in public life," the organization said.

In 2015, when the law was signed, 25 percent of Michigan's adoption and foster care agencies were faith-based. If they decline to work with same-sex couples, they're required to give applicants a list of other providers.

Follow NBC Out on Twitter, Facebook and Instagram