MARTINEZ — In what his attorney called a “Shakespearean tragedy,” Contra Costa District Attorney Mark Peterson resigned from office Wednesday, before pleading no contest to a single count of felony perjury.

Peterson entered the plea at his arraignment hearing Wednesday afternoon, just hours after the California attorney general charged him with 12 counts of felony perjury and one count of felony grand theft. Peterson illegally spent more than $66,000 in campaign cash over a five-year period, and last month a county grand jury formally accused him of willful or corrupt misconduct that warranted his removal as DA.

On Wednesday, Contra Costa Superior Court Judge Theresa Canepa sentenced Peterson to 250 hours of community service and three years of probation, during which time he is barred from running for office. His resignation means that Chief Deputy Doug MacMaster, Peterson’s appointed second in command, will likely take the helm of the office, though he has not yet been appointed acting DA.

Related Articles Contra Costa DA detained in criminal probe as Attorney General agents search his Martinez office

California attorney general takes over case against Contra Costa DA In exchange for his plea, the other 12 felony charges were dropped, as was a pending civil case sparked by a county grand jury investigation that could have resulted in his forcible removal from office.

The criminal complaint alleged Peterson stole $66,372 in campaign cash and carried an enhancement for theft exceeding $65,000. The perjury charges covered dates beginning in 2011 and ending in 2015, and allege Peterson lied on campaign-disclosure forms during those years.

Peterson got into a car and left court immediately after Wednesday’s hearing. He did not speak to reporters. His attorney, Ted Cassman, said in court Peterson had made a “tragic mistake” but added he’d done a “stellar job” as DA.

“He’s worked hard for this county,” Cassman said, later adding, “This is a Shakespearean tragedy.”

State prosecutors, though, said Peterson’s criminal offenses were “serious and sophisticated” in nature, and encouraged Canepa to separate Peterson’s actions from his office.

“The Attorney General’s Office wants to make sure every person is treated the same under the law,” prosecutor David Bass said.

Peterson’s arraignment was attended by a number of Contra Costa prosecutors and criminal defense lawyers. Every seat in the courtroom was full, as many as six deputies were on hand, and no one — not even attorneys — were allowed to use cellphones.

“It’s a story about a guy who truly dedicated his life to public service, but had this fatal flaw that he just couldn’t shake; he had to live a little bit bigger than he could afford, and it destroyed him,” said Dan Horowitz, a well-known defense attorney who was in the audience for Wednesday’s hearing. “It really does read like a tragic novel, and there’s no reason to rejoice in what happened.”

In January, the state Fair Political Practices Commission fined Peterson $45,000, finding he violated the state’s Political Reform Act nine times. Until Wednesday, he had ignored numerous calls for his resignation, including from within his office.

Last week, agents from the Attorney General’s Office briefly detained Peterson, seizing his phone and other items as part of the criminal investigation. A statement of probable cause in support of a warrant to search Peterson’s office said state prosecutors were considering whether to file felony perjury, grand theft and embezzlement charges against him.

Peterson admitted last year that from 2011-15, he’d spent money from his campaign fund on restaurant meals, movie tickets, gasoline, clothes, and other personal expenses, as well as making cash withdrawals from his account. He was treasurer of his campaign at the time and stopped only when he was informed that the fund would be subjected to a state audit.

He later said he considered the money a loan and intended to fully repay it, but his campaign-disclosure forms — signed under penalty of perjury and submitted to the Fair Political Practices Commission — said his campaign had not issued loans for those years, and made no record of the illegal spending. Peterson also didn’t indicate he’d received any loans on financial-disclosure forms submitted to the county.

Peterson agreed to pay back the campaign cash in December, saying he was “humbled and embarrassed” by his actions. He said last week that he was cooperating with the criminal investigation and ready to fight the civil accusation in court.

In May, Peterson’s rank and file held a vote of no confidence in him, which passed overwhelmingly.

Peterson was elected DA in 2010, and ran unopposed in 2014.