AUGUSTA, Maine — Dakota, the husky pardoned by Gov. Paul LePage, was granted a permanent reprieve Monday when a District Court judge approved a deal that will spare her life, but ban her permanently from the city where she attacked two dogs.

The deal was struck late last week among Kennebec County District Attorney Maeghan Maloney, attorneys for the previous owner, Matthew Perry, and attorneys for Linda Janeski, the woman who adopted the dog.

District Court Judge Valerie Stanfill swiftly approved it during a short hearing Monday at the Capital Judicial Center.

The resolution means that two pending appeals before the Maine Supreme Judicial Court have been dropped, and the question of whether the governor has the legal authority to pardon a condemned dog will remain unanswered.

According to the terms of the deal, Dakota will be permanently banned from Waterville, will live outside Kennebec County at a veterinarian’s office with a boarding facility, and must undergo training with a certified behavior expert until she is deemed adoptable.

Dakota also must be on a short leash and muzzled when being walked and must be kept in an enclosure with a six-foot tall fence or inside a building when she is not being supervised.

“I know she’s going to be in a better place, well taken care,” Perry told reporters outside the courtroom. “That’s the biggest thing. She’s a great dog. Anybody would be happy to have her.”

Maloney said the owner of the dogs that were attacked was pleased Dakota would not be allowed in Waterville.

The dog has been held at the Humane Society Waterville Area since she was picked up as a stray, except for the few days she lived with Janeski.

Dakota was determined to be a dangerous dog in March after she attacked two smaller dogs in less than a year, killing one. Both dogs were owned by the same person, who has not been identified by authorities.

The second attack led Stanfill to order that the dog be put down. But LePage on March 30 issued a pardon, turning her case into a national story and triggering questions over whether the Maine Constitution allows the governor to grant clemency to an animal.

Perry of Waterville, who owned the dog during the attacks, agreed on April 11 in Waterville District Court that Dakota should be euthanized and agreed to pay to have the procedure done. The next day, he filed an appeal to the Maine Supreme Judicial Court, triggering a stay of the euthanasia order.

On Monday, Perry withdrew his previous admission to keeping a dangerous dog that had previously killed or injured another pet, which allowed the judge to lift the euthanasia order.

Dakota still carries the label “dangerous dog” as a result of Monday’s court proceeding.

The legal matter was complicated when the Waterville shelter allowed Janeski of Winslow to adopt the dog. She sought an injunction to keep Dakota from being euthanized, which was denied in April. Janeski also has appealed to the Maine Supreme Judicial Court.

Janeski, who attended Monday’s hearing, wiped tears from her eyes during the hearing. She left the courthouse without talking to reporters.

The is nothing in the judge’s order that would prevent Janeski from adopting the dog again, Maloney said. To do that, the trainer would have to find that Janeski could handle a dangerous dog and abide by the restrictions the law imposes on owners of dangerous dogs.