For more than four years, the Minnesota Department of Health resisted, even defied, legal rulings and sought to retain 1 million blood samples from a newborn screening program designed to detect illness and study genetic diseases. The defiance ended Monday with a deal that requires destruction of the samples.

In a settlement with 21 families that sued the state over medical privacy rights, the department agreed to follow a November 2011 Minnesota Supreme Court order to destroy all blood samples in long-term storage — including those from the plaintiff families — and to pay nearly $1 million in legal costs.

Department officials said the settlement is a blow to public health because the system allowed them to test newborns’ blood for more than 50 disorders and keep the samples indefinitely for research, unless parents opted out.

But an attorney for the families said the agreement is a victory for medical privacy.

“There’s no question in my mind that they seem to think the end justifies the means,” said Scott Kelly, a Mankato attorney from one of two firms that represented the families. “But in my mind there is still a privacy right to parents and these children that they refuse to consider.”

Getting the department to abide by the court ruling was significant, Kelly said, because officials fought so hard to maintain the existing system. Two administrative law rulings sided against the department, and former Gov. Tim Pawlenty vetoed a bill that would have allowed the department to continue its long-term sample storage without explicit parental consent. But the department continued to hold out for an appeal or legislation in its favor.

Under the ruling and subsequent legislation, the department still collects blood and tests it to see if a newborn is at risk for inherited or metabolic disorders. But absent parental permission, there are limits: The state can keep blood spots with negative results for 71 days, and blood spots with positive results for two years.

The loss of the more than 1 million samples is regrettable, said Jim Koppel, deputy health commissioner. That depth allowed the state to find genetic connections to rare but severe disorders. Research using those samples has expanded the list of disorders for which newborns are tested; the state estimates that this helps 150 babies per year.

“We felt like we were doing the right thing,” Koppel said. “Turns out, we weren’t, at least by the Supreme Court.”

Even now, the issue may not be settled. The Health Department will report to the Legislature in February and present options, including legislation to permit the “opt out” system again. The department also could pursue blood collection by asking all parents to “opt in” and give consent for the blood samples to be used in research.

Koppel said that would be more expensive, and could result in inconsistent sample collection. In Michigan, which collects newborn blood samples with an “opt in” approach, about six in 10 parents specifically give such permission, he said. But research has found that parents from key demographic groups are less likely to consent, which limits the potential for identifying genetic disorders with racial or ethnic variations.

While newborn screening is important, the state had allowed the genetic blood samples to be used for research purposes that were well beyond the discovery of new ways to test for disorders, said Alan Bearder, one of the plaintiffs, whose children are 8 and 5.

Koppel said the department will destroy the blood samples expeditiously, despite any temptation to hope legislation comes in time to spare some.

The state is required to file an affidavit when destruction of the blood samples from the 21 families — along with any records — is complete. Given the state’s long resistance, Bearder remains wary.

“Until all the data is certified as destroyed,” he said, “we’re really not going to believe it.”