A federal judge in Kansas City has blocked Missouri’s eight-week abortion ban from taking effect after midnight Tuesday.

Senior U.S. District Judge Howard Sachs issued a preliminary injunction blocking the law's gestational bans, while declining to block a "non-discrimination" section prohibiting abortions on the basis of race, sex or Down syndrome.

Although not a decision on the merits, the ruling is a major victory for the Planned Parenthood clinic in St. Louis, the only remaining abortion provider in Missouri, and its medical director, Colleen McNicholas.

Both challenged the law's constitutionality in a lawsuit filed last month. In order to secure a preliminary injunction, they needed to show they were likely to prevail on the merits.

The law, which was enacted this year and set to take effect on Wednesday, would have banned the overwhelming majority of pre-viability abortions in Missouri, running afoul of more than four decades of Supreme Court precedent.

Known as HB 126 or the Missouri Stands for the Unborn Act, the law has four separate bans of abortion at eight, 14, 18 and 20 weeks of gestation. It also prohibits abortions at any stage of pregnancy if the physician "knows" the patient is seeking to terminate her pregnancy on the basis of the race or sex of the child or because it has Down syndrome.

If the eight-week ban is struck down by a court, the 14-week ban takes effect and so on with the other bans.

The law carves out exceptions only for a "medical emergency," defined as a situation in which the pregnant woman faces death or "substantial and irreversible impairment of a major bodily function." It contains no exceptions for incest or rape.

Under the law, abortion providers face from five to 15 years in prison and the loss of their medical license if they violate any of the gestational age bans.

Missouri, which has some of the harshest abortion restrictions in the country, already prohibits abortions of viable fetuses except in cases of a medical emergency.

In urging Sachs not to block the law, the state argued that Planned Parenthood does not have legal standing to challenge the law on behalf of its patients because abortion providers only have a transitory relationship with their patients.

It also argued that the law advances various state interests, including protecting innocent life, preventing fetal pain, promoting women's physical and psychological health, and protecting the integrity of the medical profession.

Planned Parenthood responded that those interests are irrelevant to the question of whether the law passes constitutional muster. And under binding Supreme Court precedent barring states from banning pre-viability abortions, it argued, the law is plainly unconstitutional.

Earlier this year, Missouri health officials refused to renew the license of the Planned Parenthood clinic in St. Louis on various grounds, which the clinic claimed were pretexts. Had a state court judge not blocked the clinic's closure, Missouri would have become the first state in the nation since 1974 without an abortion provider.

Missouri's newest abortion law was passed amid a nationwide wave of anti-abortion "heartbeat" bills prohibiting abortions when a fetal heartbeat can be detected. That can be as early as six weeks. Missouri's bill originally contained fetal heartbeat language, but that was deleted in the final version of the measure.

More than a third of states, including Kansas, have 20-week abortion bans, according to the Guttmacher Institute. Some have been struck down but others have survived judicial scrutiny.

In 2017, the last year for which figures are available, there were 6,790 resident abortions in Missouri, compared with 7,275 in 2016. Only 134 of the abortions in 2017 and only 170 in 2016 occurred at 20 weeks or later.

In his 11-page ruling, Sachs invited Planned Parenthood to challenge the anti-discrimination provisions of the law, as applied.

"Caution suggests I withhold a preliminary injunction against the anti-discrimination section, but remain open to an adequately supported renewed motion on this narrow issue," Sachs wrote.

McNicholas, the medical director of the Planned Parenthood clinic in St. Louis, said she was pleased with Sachs' ruling "protecting abortion access for most Missourians."

But she said she had serious concerns about his unwillingness to block the anti-discrimination provisions.

"That certainly will have a measurable impact on patients, people who are seeking abortions because of conditions such as Down syndrome, but also the untenable position that it places physicians in, where we are now going to have to interrogate patients about their reasons to have an abortion," McNicholas said.

"If the 28th [of August] comes and goes and we don't have this piece of the law enjoined, there will be patients we will not be able to take care of. And so the real, lived experience for those who are seeking an abortion in Missouri will be impacted."

Chris Nuelle, a spokesman for Missouri Attorney General Eric Schmitt, said the AG's office was reviewing Sachs' order and deciding on it next steps.

"Like attorneys general who came before him," Nuelle said in an email, "Attorney General Eric Schmitt is tasked with defending the laws of the state and is dedicated to protecting Missourians, both born and unborn."

"On a separate note," Nuelle said, "as the father of a child with special needs, Attorney General Schmitt is particularly sensitive to suggestions that an unborn child who will have special needs is any lesser of a human being, and we're glad that provisions relating to that issue were left in place in the judge's ruling today."

Dan Margolies is a senior reporter and editor at KCUR. You can reach him on Twitter @DanMargolies.