Prosecutors who bend or even break the rules to win a conviction almost never face any punishment. But even given lax controls, the blatant and systemic misconduct in the Orange County district attorney’s office in Southern California stands out. In a scheme that may go back as far as 30 years, prosecutors and the county sheriff’s department have elicited illegal jailhouse confessions, failed to turn over evidence that is favorable to defendants and lied repeatedly in court about what they did.

These unconstitutional abuses are all the more troubling because Orange County is not some corrupt backwater with one rogue prosecutor. With more than three million residents, the county itself is more populous than nearly half the states in the country. Its district attorney’s office employs 250 prosecutors. In March, a California judge, Thomas Goethals, removed all of them from the county’s highest-profile murder prosecution in years because misconduct had tainted the entire office’s handling of the case. He reassigned the case to the California attorney general, Kamala Harris, a ruling her office is appealing.

The case involved a 2011 mass shooting in which eight people were killed by a man named Scott Dekraai. Mr. Dekraai pleaded guilty in 2014, and a jury will consider whether to sentence him to death or life in prison. In early 2014, Mr. Dekraai’s public defender filed a 505-page motion detailing illegal and unconstitutional acts by prosecutors and the sheriff’s department, arguing that this record should take the death penalty off the table. Among other things, the defense argued, deputies intentionally placed informants in cells next to defendants facing trial, including Mr. Dekraai, and hid that fact.

Image Judge Thomas Goethals Credit... Pool photo by Mark Boster

The informants, some of whom faced life sentences for their own crimes, were promised reduced sentences or cash payouts in exchange for drawing out confessions or other incriminating evidence from the defendants. This practice is prohibited once someone has been charged with a crime. Even when using an informant is allowed, defendants and judges must be told of the arrangement. That did not happen in Orange County. As Mr. Dekraai’s defense lawyer discovered, the sheriff’s department kept secret a computer file showing where jailhouse informants were placed that went back decades. The prosecutor’s office kept separate files of data on informants and their deals. Some of the informants have helped law enforcement repeatedly in exchange for favors, a fact that is highly relevant in weighing their credibility.