A federal judge on Monday blocked enforcement of North Dakota’s recently enacted ban on most abortions, calling it “invalid and unconstitutional.”

The law under challenge, which was set to take effect Aug. 1, would have imposed by far the country’s most stringent limit on abortions. With few exceptions, it would bar the procedure once a fetal heartbeat is detected, often about six weeks into pregnancy — a point when many women are not aware they are pregnant.

From the moment in March when it was adopted, most legal experts said that the law would not survive because it posed a direct challenge to Supreme Court guidelines, which state that a woman has a right to an abortion until the fetus is viable outside the womb. Viability must be determined by a physician and often occurs around 24 weeks into pregnancy.

Some anti-abortion leaders and politicians argued that the presence of a heartbeat is in itself a form of viability. They expressed hope that the Supreme Court would revisit the issue.