The defendant in a contentious domestic violence case in which a judge disqualified the entire York County District Attorney’s Office from handling the prosecution has accepted a plea deal in Cumberland County that keeps him out of jail.

Paul Olsen, 34, formerly of Eliot and now living in New Hampshire, pleaded no contest on Wednesday in the Cumberland County Courthouse in Portland to a felony domestic assault charge, a misdemeanor domestic assault charge and a misdemeanor criminal mischief charge.

Justice Nancy Mills found Olsen guilty and sentenced him to a two-year deferred disposition on the felony charge with terms that if he stays out of trouble in that time, the felony charge will be dismissed. She sentenced him to 18 months in jail on the misdemeanor charges, which he has already served while the case was pending.

The sentence comes as a blow to the York County District Attorney’s Office, which withdrew a settlement offer last year in which Olsen had agreed to plead guilty to a more serious felony count of aggravated assault and serve five years of a 10-year sentence in prison. York County Assistant District Attorney Thomas Miscio scuttled that plea agreement on Jan. 3, 2014, after he took over the case and decided the proposed sentence was too lenient, Olsen’s attorney Amy Fairfield said.

Miscio declined to comment on Wednesday on the new plea agreement reached in Cumberland County. York County District Attorney Kathryn Slattery did not return a phone call seeking comment.

Mills disqualified the York County prosecutors after finding Miscio had knowingly received confidential documents written by Olsen’s attorneys that contained the defense’s trial plans. Miscio read the documents without informing the court of the breach, as he is required to do, Mills ruled.

Mills learned of the breach on May 4, the day before Olsen was due to stand trial in York County Superior Court in Alfred on charges that he assaulted and raped his former girlfriend in her home in Eliot in 2012. The judge immediately canceled the trial and said in a written order that Miscio’s actions have tainted his office’s ability to prosecute the case.

It is unclear whether Miscio will face further sanctions from the Board of Overseers of the Bar, which investigates professional misconduct of lawyers and imposes discipline. Jacqueline Rogers, the board’s executive director, said Wednesday that the board had nothing to share publicly at this time.

Slattery has requested a hearing before Mills in the future to re-open discussions about Miscio’s actions, but that hearing date has yet to be set.

Olsen spent 32 months in the York County Jail in Alfred from the time of his arrest on Sept. 19, 2012, until Mills reduced his bail from $100,000 to $1,000 in May after Cumberland County District Attorney Stephanie Anderson took over the case. Fairfield had a pending motion to dismiss the case against Olsen outright when she and Anderson reached Wednesday’s plea agreement.

Anderson said she spoke to Olsen’s ex-girlfriend four times before reaching the plea agreement and said that the woman, who has since moved to California with her and Olsen’s young children, preferred to resolve the case rather than face Fairfield’s motion to have the case dismissed or rescheduled for trial.

Anderson read aloud part of a letter from Olsen’s ex-girlfriend that said she disagreed with the terms of the plea deal, calling it a “slap on the wrist.”

“She doesn’t like that he’s ultimately going to be convicted of misdemeanors. She doesn’t like that he’s being granted liberty, but she does agree to the disposition because she wants to put this behind her,” Anderson said.

Anderson said she feels the disposition was fair and that it gives Olsen the opportunity to turn his life around with a serious penalty of being sentenced again if he fails to comply with the terms of his deferred disposition.

Olsen’s case also raised a scandal within the Eliot Police Department unconnected to its officers’ investigation of Olsen’s crimes.

Fairfield sought to introduce evidence revealed by the Eliot department’s former deputy chief that the majority of the department’s officers routinely lied in their patrol reports. Fairfield sought to use that information to undermine the officers’ credibility in Olsen’s case, and Mills ruled that Fairfield could have cross-examined those officers about falsified reports if the case had gone to trial.

Fairfield said that though the falsified reports are now moot in Olsen’s case, it remains relevant in any future case involving Eliot police.

“I think there are a couple officers implicated in the scandal who are still employed in Eliot,” Fairfield said. “I think those issues regarding their credibility are still in play.”

As part of Wednesday’s plea agreement, charges of burglary, aggravated assault, gross sexual assault, domestic violence stalking and criminal threatening were dismissed against Olsen.