MONTGOMERY, Ala. — A federal judge blocked an Alabama abortion ban Tuesday that would have made the procedure a felony at any stage of pregnancy in almost all cases.

U.S. District Judge Myron Thompson issued a preliminary injunction blocking Alabama from enforcing the law, which would have called for a sentence of 10 years to life in prison for the abortion provider with no exceptions for rape or incest.

Alabama legislators approved the measure this year, hoping to mount a court challenge to abortion rights. Abortion providers sued to stop the law from going into effect.

Randall Marshall, executive director of the American Civil Liberties Union, said the decision was expected.

Abortion Alabama governor signs law
This photograph released by the state shows Alabama Gov. Kay Ivey signing a bill that virtually outlaws abortion in the state on Wednesday, May 15, 2019, in Montgomery, Ala.
AP

The law was set to take effect next month and is the most hardline of the anti-abortion measures enacted this year as states emboldened by the new conservatives on the U.S. Supreme Court take aim at Roe v. Wade, the 1973 ruling that legalized abortion nationwide.

RELATED: Abortion, immigrants, LGBT rights top high court's new term

RELATED: Abortions in US fall to lowest number since becoming legal