Attorneys general of the states who brought the lawsuit expressed relief over the ruling.

“Today’s decision is a major victory that ensures that some of our most vulnerable residents are able to continue to access the health care they deserve,” said Rob Bonta, California’s attorney general and one of the plaintiffs.

Even with the new ruling, the Medicaid work requirement is still expected to lead to significant losses in coverage. The nonpartisan Congressional Budget Office estimated that, based on the original law, around five million people would become uninsured because of the work requirement, including many people who were working but unable to handle the paperwork to prove it. Medicaid covers about 66 million Americans who are poor or disabled.

States have been racing to prepare for the new law by the end of the year. They must build systems to evaluate who qualifies for the law’s exceptions, and to measure the work hours of those who do not.

Before the regulation was published, many had been preparing lists of serious health conditions that could be automatically matched with applicants’ medical records.

Nebraska and Montana have enacted their work requirements early.

In addition to the District of Columbia, the states that brought the lawsuit were Arizona, California, Colorado, Connecticut, Delaware, Hawaii, Illinois, Kentucky, Maine, Maryland, Massachusetts, Michigan, Minnesota, Nevada, New Jersey, New Mexico, New York, North Carolina, Oregon, Pennsylvania, Rhode Island, Vermont, Virginia, Washington and Wisconsin.