A federal judge issued a ruling Tuesday blocking an Alabama law that would make abortion a felony in nearly all situations, regardless of the stage of the pregnancy.

U.S. District Judge Myron Thompson granted a motion for a preliminary injunction, temporarily preventing the law from being enforced as a lawsuit over the law brought by abortion providers moves forward.

ALABAMA JUDGE THROWS OUT TEEN'S LAWSUIT AGAINST ABORTION CLINIC ON BEHALF OF ABORTED CHILD

"The court is persuaded that the plaintiffs are likely to succeed in showing that the Act violates an individual's constitutional right to obtain a pre-viability abortion, and thus that it violates her constitutional rights," the ruling said, noting that "banning abortion before viability violates Supreme Court precedent."

The law, known as the Alabama Human Life Protection Act, would make it a felony for anyone to perform an abortion, except in situations where a doctor determines that there is a "medical emergency" related to the mother's physical condition or if the fetus has a "lethal anomaly" that would cause it to be stillborn or die soon after death.

The law would not have punished women receiving abortions.

Alabama legislators approved the measure this year, hoping to mount a court challenge to abortion rights.

The law was set to take effect Nov. 15 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.

The Associated Press contributed to this report.