The U.S. House has rejected an amendment to a funding bill that sought to allow adoption agencies to refuse gay and lesbian couples.

Introduced by Representative Robert Aderholt, a Republican from Alabama, the amendment was attached to the spending package in July. It would prohibit federal, state and local governments from denying funds to adoption agencies that have “declined or will decline to provide, facilitate or refer for a child welfare service that conflicts with … the provider's sincerely held religious beliefs or moral convictions.” State and local governments that violate the law would be penalized with a fifteen percent cut in federal funding.

The amendment was stripped out of the legislation during the conference committee process, according to the American Civil Liberties Union (ACLU).

On Wednesday, the House voted 361-61 in favor of the spending package and sent the legislation to President Donald Trump, who is expected to sign it. Passage means a government shutdown near Election Day will be averted.

Ian Thompson of the ACLU said that the amendment would have hurt children.

This amendment would have placed the religious and moral beliefs of certain taxpayer-funded child welfare service providers above the best interests of the children in their care,” Thompson said in a statement. “The only determination that should govern the actions of these providers is what is in the best interests of the child. No family should ever be told they are not qualified to serve as foster or adoptive parents because they are LGBTQ or the ‘wrong’ religion. The successful defeat of the Aderholt Amendment sends a clear message: There is no place for taxpayer-funded discrimination in the child welfare system.”

Laws allowing adoption agencies to refuse gay couples have been enacted in several states, including Alabama, Michigan, Mississippi, North Dakota, South Dakota, Texas, Virginia, Oklahoma and Kansas.