MONTGOMERY, Ala. (AP) — 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.

READ MORE: Could these state abortion bans help the movement to overturn Roe v. Wade?

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

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.