More than four years after a Massachusetts lab chemist confessed to manipulating drug test results, the state’s highest court has called on prosecutors to reverse potentially thousands of tainted convictions.

The chemist, Annie Dookhan, may have played a role in more than 20,000 drug cases during her eight and a half years at a state lab, but to date prosecutors have resisted mounting a wholesale revisiting of the convictions that resulted at least in part from Dookhan’s work.

At one point, prosecutors argued that they had no obligation to inform those convicted of their possible innocence. Another prosecutor suggested that many of the defendants might be too poor or busy dealing with more pressing issues, such as mental illness or addiction, to have any desire to contest old drug convictions. And when prosecutors tried to alert all of the affected defendants of their potential innocence — four years after Dookhan’s confession — the mailed notice they sent was “wholly inadequate,” according to the court. As of last November, fewer than 2,000 defendants had sought or received relief from their drug convictions.

The justices of the Massachusetts Supreme Judicial Court last week effectively declared an end to the delays.

“The extraordinary magnitude of Dookhan’s misconduct has left us with only poor alternatives,” the court’s decision said. In a concurring opinion, two justices expressed frustration with “the unacceptably glacial systemic response to date” and called on prosecutors to dismiss “a truly significant number of the roughly 20,000” Dookhan cases.

The court’s decision requires district attorneys to act quickly: By mid-April, they must review all Dookhan cases individually and determine which ones they are willing to dismiss and which ones they will stand behind. Prosecutors will then have 30 days to notify the defendants whose convictions remain that they can request a new trial, should they decide to mount a challenge. The court specified that district attorneys will only be allowed to re-prosecute defendants if they first certify that they have sufficient untainted evidence with which to make their case.

Among the 20,000 or so defendants affected, those who pleaded guilty before their Dookhan-signed test results came back from the lab are not eligible for relief, since Dookhan’s bad evidence didn’t influence their decisions, the court said. Prosecutors must also draw up a list of these individuals by mid-April.

“It’s a huge victory,” said Matthew Segal, legal director of the ACLU of Massachusetts and a lawyer for some of the defendants. “If the district attorneys do what they’ve been asked to do, large numbers of these thousands upon thousands of cases are going to be dismissed outright.”

The decision comes as another Massachusetts drug lab scandal is working its way through the courts. In this latest episode, which surfaced in 2013, Sonja Farak was found by the state attorney general to have worked on drug samples while high herself, over a period of about eight years. There is still no definitive list of drug defendants potentially affected by Farak’s misconduct.

Crime labs have been hit by scandals in several other U.S. cities as well — including San Francisco, Houston, Oklahoma City and St. Paul. However, one facet of the Dookhan saga that stood out was prosecutors’ seeming unwillingness to promptly and comprehensively notify the Dookhan defendants of their situation, Segal said.

In its decision, the court directly criticized some of the prosecutors’ actions in handling the scandal and reaching out to defendants.

For instance, the 21,880 notices that district attorneys mailed to Dookhan defendants in September lacked essential information, such as the fact that many of them are entitled to a legal presumption that the drug analysis used in their case was “tainted by egregious government misconduct.” Other shortcomings included having the letter sent in an envelope that might easily be mistaken for junk mail, providing a sub-par Spanish translation and making no effort to post a public notice, such as in newspapers or on social media, to reach those whose addresses could not be found.

The court also expressed skepticism about prosecutors’ argument that few Dookhan defendants would be interested in “reopening a closed chapter in their lives,” instead pointing out that some defendants would have strong incentives to challenge their drug convictions “given the serious and pervasive collateral consequences” associated with them. These consequences could include deportation for lawfully residing noncitizens, as well as loss of access to public housing, federal financial aid, driver’s licenses and various jobs, professional licenses and government benefits.

The burden now rests squarely with prosecutors to “reduce substantially” the number of defendants with Dookhan-tainted drug convictions on their records, according to the court’s decision.

“The decision-making process will be informed by the state of the evidence and the seriousness of the case,” said Jake Wark, a spokesman for the Suffolk County District Attorney’s office. “We expect to be able to fulfill our responsibility under those protocols, and in fact we are ready to.”