AUGUSTA — Dakota the husky, whose court-ordered death sentence has been in legal limbo following an appeal and a high-profile pardon from Maine’s governor, won a full reprieve on Monday from a euthanasia order stemming from deadly attacks in Waterville.

The dog will live at least initially at a veterinary hospital with a boarding kennel and be trained by a canine behavior expert, following a court-approved settlement. The location of the facility and training expert was kept secret by both the prosecutor, District Attorney Maeghan Maloney, and defense attorney Darrick Banda, who said the hospital and trainer asked for anonymity.

Maloney said immediately before the hearing Monday that Dakota will remain in Maine. An earlier agreement to have Dakota placed with a New Hampshire rescue group for training as a sled dog was derailed after one of the attorneys objected to it, Banda said.

“Hopefully everybody can ride off into the sunset and Dakota can live for another day,” Banda said just prior to the court hearing.

Matthew D. Perry, Dakota’s previous owner, attended Monday’s court hearing and called the settlement “the best agreement that could possibly be made.” Perry had owned Dakota for five years, raising her from a puppy, he said.

“I’m happy with it; I believe everybody’s happy with it,” Perry said.

The compromise appears to bring to a close a 14-month saga that started when Dakota killed another dog in Waterville. Then in February of this year, Dakota escaped from home again and seriously injured another dog owned by the same family. The case drew the attention of Gov. Paul LePage, who issued a documented “pardon” to Dakota, was appealed to the Maine Supreme Judicial Court, and raised questions about the appropriate punishment for dogs deemed dangerous.

Banda said he and attorney David Bobrow helped broker a deal that appeared to have all the attorneys on board. Nine lawyers went into chambers — including two representing LePage — to discuss the case with the judge prior to the hearing at the Capital Judicial Center.

Dakota remained at the Humane Society Waterville Area on Monday and did not appear at the Capital Judicial Center, where her fate was decided.

Maloney said the neighbor whose dogs were attacked was in agreement with the settlement but wanted Dakota kept out of Waterville permanently. The neighbor, who was not named in the complaint, was not at Monday’s hearing. Maloney said the woman indicated she would be at work.

Maloney said that the agreement would mean the dog remains outside Kennebec County initially and permanently out of Waterville.

In court, she said, “We have an agreement that this is in the best interest of the public and in the best interest of Dakota as it is something that all parties would like to see happen.” She also told the judge that there was a requirement that Dakota be tethered and kept in a secure enclosure.

LePage had issued a “pardon” for Dakota after learning about the doomed dog from a board member of the Waterville shelter. There was only a brief mention of the pardon at the hearing on Monday when Stanfill asked whether a pending a motion to intervene filed by Gov. LePage was being withdrawn.

“Yes, it is your honor,” said Catherine Connors, who was representing LePage. Brent Davis, governor’s counsel, was in the courtroom as well.

In a letter sent to Maine Attorney General Janet Mills, LePage had earlier indicated he wanted to defend his full power to grant pardons, including in Dakota’s case. It’s not clear whether LePage’s pardon order had any bearing on the settlement reached Monday for Dakota.

Video cameras from four television stations filmed Monday’s hearing, which attracted 11 people from the media.

The settlement also appears to stop the case from an appeal before the state supreme court. It also says a separate dog behavioral expert would have to evaluate Dakota prior to any adoption.

Dakota, now 5 years old, was declared a dangerous dog in May 2016 after getting loose and killing Zoe, a smaller dog belonging to neighbors.

At that time, Dakota’s owner, Perry, was ordered to keep Dakota confined, but Dakota got loose again in February. The dog went back to the same neighbors’ house, attacking their new dog, Bruce Wayne, and biting his throat, according to Maloney.

Dakota was found picked up as a stray and taken to the humane society, which said the dog did well on aggression tests and was a “model resident” at the shelter.

Dakota was adopted by Linda Janeski of Winslow, who identified herself previously as the mother of Perry’s ex-girlfriend.

Janeski indicated she was unaware of the March 21 court date when Judge Valerie Stanfill found that Perry had committed the civil offense of “keeping a dangerous dog” and ordered Dakota euthanized within 48 hours. A series of court postponements helped keep that death sentence for Dakota at bay.

Perry, 37, was in court Monday, sitting at the defense table with Banda and Bobrow. Perry withdrew his admission to the prior civil violation and admitted to a lesser one that does not include a reference to the earlier attack on Zoe. He was fined $250.

“I do not mind paying a fine to make sure Dakota stays alive,” Perry said after the hearing.

Banda explained, “When you take the prior attack away, it takes the mandatory euthanasia away.”

Janeski stood in court to say she had agreed to the settlement as well. She was accompanied by her attorneys, Jeffrey Edwards and Bonnie Martinolich.

Edwards said the agreement on sparing Dakota would give everyone peace of mind.

“She’s a great dog and she’ll just be a better dog,” Martinolich said.

Betty Adams — 621-5631

[email protected]

Twitter: @betadams