A federal judge has ruled that some provisions of a St. Louis ordinance banning discrimination based on reproductive health decisions violate the U.S. Constitution and Missouri law.

A lawsuit questioned the city’s 2017 ordinance that bars employers from hiring or firing workers based on whether they have had an abortion, been pregnant outside marriage, or used contraceptives or artificial insemination. Landlords also can’t refuse tenants based on those criteria.

Judge Audrey Fleissig’s ruling said the ordinance violated the First Amendment rights of Catholic elementary schools and Our Lady’s Inn, a home for pregnant homeless women, by requiring them to employ or house people who are not abortion opponents. She ruled that a provision requiring O’Brien Industrial Holdings LLC, a company operated by a devout Catholic, to offer health care covering abortion and contraception violated Missouri law.

But the judge’s order stopped short of declaring the ordinance unconstitutional. Fleissig wrote that it remains valid for organizations that “hold no contrary expressive or religious beliefs.” The ruling, issued Sunday, offered no explanation of how the city should draw that distinction.

Attorney Sarah Pitlyk of the anti-abortion law firm the Thomas More Society said the ruling “exposes the law for the sham that it is.” She said in a statement that the ordinance is “an attempt to suppress the viewpoint of those who believe that abortion is harmful or wrong by making it impossible for them to operate in accordance with their beliefs within the City of St. Louis.”

A message seeking comment from Mayor Lyda Krewson’s office wasn’t immediately returned on Thursday.

St. Louis Archbishop Robert Carlson lauded the decision, while Alderwoman Megan Ellyia Green, who sponsored the bill, called it disappointing.

The St. Louis Board of Aldermen adopted the ordinance in February 2017 and the Thomas More Society filed suit three months later on grounds that it could force employers or landlords to go against their religious beliefs. Carlson has called the ordinance “a marker of our city’s embrace of the culture of death,” and said after its adoption that the archdiocese and its affiliates, including the schools, wouldn’t comply.