A federal judge on Tuesday blocked a near-total ban on abortions from taking effect next month in Alabama, ensuring the procedure remains legal and available in the state while the case winds its way through the courts.

In ruling against the Alabama law — the most far-reaching anti-abortion measure passed by state lawmakers this year — Judge Myron H. Thompson of the United States District Court for the Middle District of Alabama wrote that it violates Supreme Court precedent and “defies” the Constitution.

Alabama was among several states to approve restrictive laws designed to provoke a renewed legal battle over abortion rights, with the aim to reach the United States Supreme Court and topple Roe v. Wade, the landmark 1973 decision that legalized abortion up to the point when a fetus is viable outside the womb, usually about 24 weeks into a pregnancy.

Federal judges in six other states have blocked laws that would ban abortions after what becomes the fetus’s heartbeat can be detected from going into effect, and judges in two other states have temporarily blocked laws that would ban abortions after 18 weeks. Alabama’s law would have gone into effect Nov. 15.