The Supreme Judicial Court on Thursday ordered the dismissal of thousands of additional drug convictions due to the misconduct of Amherst drug lab chemist Sonja Farak, some dating back as far as 2004.

"We conclude that Farak's widespread evidence tampering has compromised the integrity of thousands of drug convictions apart from those the Commonwealth has agreed should be vacated and dismissed," wrote Justice Frank Gaziano in the court's 61-page unanimous decision. "Her misconduct, compounded by prosecutorial misconduct, requires that this court exercise its superintendence authority and vacate and dismiss all criminal convictions tainted by government wrongdoing."

Farak, who worked at the drug lab for nearly nine years, has pleaded guilty to stealing drug samples to feed her own addiction. The state's prosecutors already agreed to dismiss 8,000 cases in which Farak signed the drug certificate.

But during the course of the case, two assistant attorneys general were found to have improperly withheld evidence from defendants related to the time frame in which Farak was addicted to drugs.

The public defenders' office, working with the ACLU and representing people convicted of drug crimes, had asked the court to dismiss the convictions of everyone who had drugs tested at the lab during Farak's time there.

The SJC's ruling orders the dismissal of all cases involving methamphetamine that were tested at the Amherst lab beginning in August 2004, when Farak first started working there. Farak has said she stole only samples of methamphetamine between 2004 and 2008.

The court also ordered the dismissal of all convictions based on drugs tested at the Amherst lab between Jan. 1, 2009 and Jan. 18, 2013, the date the lab closed. This is the time frame in which Farak admitted to more widespread theft of drugs.

Farak said during earlier court proceedings that she stole both lab standards and evidence in those years, manipulating a computer system to assign herself the drug samples that she wanted to use. She would counterfeit drugs and alter documents to hide her theft.

In a previous case involving misconduct by chemist Annie Dookhan, who falsified drug test results at the state's Hinton drug lab, the SJC ruled that prosecutors should consider each case individually to determine whether it should be dismissed.

In this case, however, Gaziano wrote that the misconduct by both Farak and the assistant attorneys general was "so intentional and so egregious" to warrant the even stronger response of blanket dismissals.

Gaziano wrote that based on the evidence, a far larger number of defendants than just those whose drug certificates were signed by Farak could have been tainted. Farak admitted to tampering with other chemists' samples, altering the weight on drug receipts before another chemist tested a sample, and replacing stolen drugs with counterfeit drugs.

Gaziano wrote that any manipulation of the evidence that calls into question the accuracy of the drug certificates or prevents later retesting "diminishes the reliability and integrity of the forensic testing at the Amherst lab, and also reduces public confidence in other drug certificates from other laboratories."

He wrote that since Farak could not identify which samples she tampered with, that calls into question the reliability of all samples tested at the lab during the time period in which there was evidence that Farak had been tampering.

An exact number of cases to be dismissed was not immediately available.

The SJC also asked a court committee to revise the state's rules of criminal procedure to better define a prosecutor's duty to disclose exculpatory evidence.