A federal judge has cleared the U.S. Department of Health and Human Services to resume sharing limited personal data of certain Medicaid enrollees with immigration enforcement officials starting Monday, dealing a blow to states that had sued the administration over privacy concerns.

In a ruling issued last week, U.S. District Judge Vince Chhabria in San Francisco said HHS can resume the exchange but only within a narrowly defined scope tied to immigrants residing in the United States illegally. For now, the judge said HHS may hand over “basic biographical, location and contact information.”

Chhabria wrote that the sharing is “clearly authorized by law” and that the agencies had “adequately explained their decisions.” He also said the court’s ongoing restrictions mean HHS and the Centers for Medicare and Medicaid Services cannot provide detailed, sensitive medical information about enrollees to the Department of Homeland Security or Immigration and Customs Enforcement while the lawsuit continues.

The judge also limited the data that can be transferred from the 22 plaintiff states. HHS and CMS cannot hand over Medicaid data about U.S. citizens or legal immigrants in those states, according to the ruling.

The case traces back to earlier orders Chhabria issued while considering the states’ challenge. In August, he blocked HHS from sharing personal data—including home addresses—with ICE. In December, Chhabria extended that temporary order, and his latest decision followed after the temporary block expired on Jan. 5.

In explaining why he initially blocked broader sharing, Chhabria wrote that the new federal policies were “totally unclear about what that information would be, why it would be needed for immigration enforcement purposes, and what the risks of sharing it with DHS would be.”

It was not immediately clear Monday whether HHS had resumed sharing under the new limits, and an HHS spokesperson did not respond right away to a request for comment, according to the report.

The underlying Medicaid issue is tied to eligibility rules and the emergency-services exception required under federal law. Immigrants living in the U.S. illegally, and some people who are lawfully present, are not allowed to enroll in Medicaid, which provides nearly free coverage for health services. Federal law, however, requires states to provide emergency Medicaid that pays only for lifesaving services in emergency rooms to anyone, including non-U.S. citizens.

The AP reported that HHS first shared personal data on millions of Medicaid enrollees in June, and that in July CMS entered into a separate agreement giving DHS daily access to view personal data—including Social Security numbers and home addresses—for all of the program’s 77 million enrollees. Neither agreement was announced publicly, the report said, and the disclosures prompted the states’ lawsuit.

CMS, the report said, stated in November that its intention to provide the data to ICE was “consistent with federal laws” and meant to “advance administration priorities related to immigration.” The court fight has unfolded alongside broader immigration enforcement actions that have involved multiple federal agencies, and immigration advocates have warned that sharing personal data could deter people from seeking emergency medical care for themselves or their children.