ST. LOUIS — A judge issued an order Friday ensuring Missouri’s only abortion clinic can continue providing abortions, acting just hours before the St. Louis Planned Parenthood facility’s license was set to expire.

The Missouri Department of Health and Senior Services had said it would not renew the clinic’s license, citing concerns with “failed abortions,” compromised patient safety and legal violations at the clinic. Agency officials also insisted upon interviewing additional physicians at the clinic as part of an investigation.

With the license set to expire at midnight Friday, Planned Parenthood pre-emptively sued this week and argued that the state was “weaponizing” the licensing process. Planned Parenthood had said that absent court intervention, Missouri would become the first state without an abortion clinic since the U.S. Supreme Court’s 1973 Roe v. Wade ruling that legalized the procedure nationwide.

St. Louis Circuit Judge Michael Stelzer issued a temporary restraining order preventing Missouri from taking away the clinic’s license. He said Planned Parenthood “has demonstrated that immediate and irreparable injury will result” if its abortion license is allowed to expire.

The clinic’s license “shall not expire and shall remain in effect” until a ruling is issued on Planned Parenthood’s request for a permanent injunction, according to Stelzer’s ruling. A hearing is set for Tuesday morning.

The nearest clinic performing abortions is just across the Mississippi River in Granite City, Illinois, less than 10 miles (16 kilometers) from the Planned Parenthood facility in St. Louis. Planned Parenthood’s abortion clinic in the Kansas City area is in Overland Park, Kansas, just 2 miles (3 kilometers) from the state line. State figures show a handful of Missouri hospitals also perform abortions, but those are relatively rare.

The fight over the clinic’s license comes as lawmakers in conservative states across the nation are passing new restrictions that take aim at Roe. Abortion opponents, emboldened by new conservative justices on the Supreme Court, are hoping federal courts will uphold laws that prohibit abortions before a fetus is viable outside the womb, the dividing line the high court set in Roe.

Louisiana, Georgia, Kentucky, Mississippi and Ohio have enacted bills barring abortion once there’s a detectable fetal heartbeat, as early as the sixth week of pregnancy. Missouri lawmakers recently approved an eight-week ban on abortion. Alabama’s gone even further, outlawing virtually all abortions, even in cases of rape or incest. None of the bans has taken effect, and all are expected to face legal challenges.

“Today is a victory for women across Missouri, but this fight is far from over,” Planned Parenthood Federation of America CEO Dr. Leana Wen said in a statement. “We have seen just how vulnerable access to abortion care is here — and in the rest of the country.”

The number of abortions performed in Missouri has declined every year for the past decade, reaching a low of 2,910 last year. Of those, an estimated 1,210 occurred at eight weeks or less of pregnancy, according to preliminary statistics from the state health department.

Missouri women also seek abortions in other states. In Kansas, about 3,300 of the 7,000 abortions performed in 2018 were for Missouri residents, according to the state’s health department. Illinois does not track the home states of women seeking abortions.