A federal judge has ruled that Medicaid work requirements undermine the program’s mission of providing healthcare for the needy, dealing a blow to the Trump administration.

The US district judge James E Boasberg in Washington DC blocked work requirements for low-income people in two states, Arkansas and Kentucky, on Wednesday. He found that the states’ requirements pose numerous obstacles to getting healthcare that have gone unresolved by federal and state officials.

Boasberg sent the federal health and human services department back to the drawing board. But he stopped short of deciding the central question of whether work requirements are incompatible with Medicaid, a federal-state program that traditionally allows states broad leeway to set benefits and eligibility.

HHS approval of the Arkansas work requirement was “arbitrary and capricious because it did not address … whether and how the project would implicate the ‘core’ objective of Medicaid: the provision of medical coverage to the needy,” wrote Boasberg. The judge used similar language in his ruling on Kentucky.

The Trump administration said it would press on despite the ruling, but did not specify its next steps.

Work requirements are already in effect in Arkansas, but Kentucky’s program has been on hold because of lawsuits. Both states want “able-bodied” adults who get health insurance through the Affordable Care Act’s Medicaid expansion to work, study, volunteer or participate in “community engagement” activities.

About six in 10 adults on Medicaid already work in low-wage jobs, according to the nonpartisan Kaiser Family Foundation. Most of those not working cite reasons such as poor health, caring for an elder or child, or going to school.

The Kentucky governor, Matt Bevin, said his state would appeal. Bevin, a Republican, has threatened to end Kentucky’s Medicaid expansion covering more than 400,000 people if work requirements are ultimately struck down.

“We have one guy in Washington who thinks he owns Kentucky,” said Bevin, apparently referring to the judge. “We’re right, and we’ll be right in the end. And one guy can gum up the works if he wants, for a while, but this, too, shall pass.”

The Arkansas governor, Asa Hutchinson, also a Republican, said he was disappointed by the decision and would publicly address it on Thursday.

The GOP leader of the Arkansas senate said he did not believe the ruling jeopardized the future of Medicaid expansion, which covers more than 200,000 residents. About 18,000 have lost coverage as a result of the work requirements.

“I don’t think there’s any reason for the state to panic,” said the senate president, Jim Hendren, who is also the governor’s nephew. “This is another obstacle in our path to try to do the best we can in Arkansas with the chips the federal government and the judiciary gives us.”

Advocates for the poor say that Medicaid is a healthcare program and that work requirements have no place in it.

“It is nonsensical and illegal to add obstacles to Medicaid for large groups of individuals who are already working, or full-time healthcare providers for family members, or suffering chronic health matters,” said Jane Perkins, legal director of the National Health Law Program, a not-for-profit organization that sued the government.

“Work should not be a key to healthcare access.”

The Trump administration is not giving up, said the head of the Centers for Medicare and Medicaid Services.

“We will continue to defend our efforts to give states greater flexibility to help low-income Americans rise out of poverty,” Seema Verma said in a statement.

Donald Trump supports work requirements for public programs across the government. Last year, he signed an executive order directing cabinet agencies to add or strengthen work requirements for programs including subsidized housing, food stamps and cash welfare.

HHS had already acted. Early in the administration, top officials invited states to apply for waivers that would allow Medicaid work requirements. Verma says she believes work is important to improving the health and wellbeing of Medicaid recipients.

Eight states have had their requests approved, though not all have put their programs in place, according to the Kaiser Family Foundation. Requests from seven others are pending. In one of those states, Virginia, a work requirement was key to getting the legislature to approve Medicaid expansion.

Nationally, some 12 million people are covered by the Medicaid expansion, a key component of Barack Obama’s healthcare law adopted by 37 states. Officials in GOP-led states have argued that work requirements and other measures such as modest premiums are needed to ensure political acceptance for the expansion.

Overall, Medicaid is the government’s largest health insurance program, covering about one in five Americans, ranging from many pregnant women and infants to severely disabled people and elderly nursing home residents.

Boasberg was nominated to the federal bench by Obama.