Eighteen alleged fighting dogs that were facing a potential death sentence in Ontario will be sent to the U.S. for rehabilitation after a months-long negotiation to save their lives.

A Chatham, Ont., court has ordered three people accused of running a dogfighting ring to surrender ownership of the banned pit bulls to the Ontario Society for the Prevention of Cruelty to Animals, which has been holding the animals since seizing them in October 2015.

The court further ordered the OSPCA -- which had applied to destroy the dogs -- to send the animals to a special facility called Dogs Playing for Life in Florida.

The Crown attorney, the OSPCA and the dogs' three owners reached an agreement on a solution for the dogs in court last Thursday, lawyers for those involved said.

Dog Tales, an opulent dog rescue and horse sanctuary north of Toronto, played a crucial role in the negotiations by pledging to pay for the care and transport of the dogs. It is expected to announce details of the agreement regarding the animals Tuesday morning.

"I am super excited -- it has been a long battle and I'm very happy that these dogs are getting this chance," said Rob Scheinberg, who owns Dog Tales along with his wife.

Scheinberg said he fought hard for the dogs because he owned a pit bull for 17 years and is against Ontario's breed-specific legislation that bans them.

It has been a lengthy legal journey for the dogs.

In the fall of 2015, police and OSPCA agents raided a compound in Tilbury, Ont., and seized 31 dogs -- all pit bulls. The raid led to charges against four people and later a fifth, much of them weapons and animal cruelty charges, along with provincial charges for owning pit bulls.

During that raid, officials came across a grim scene in a building at the back of the property, behind a sign reading "Dirty White Boy Kennels," as described by an OSPCA affidavit filed with the court.

Inspectors seized more than 200 items that day, documents said, including medical kits with injectable solutions and vitamin supplements, suture and skin staple kits, syringes and surgical tools, lists of names of dogs, training and weight schedules, a training kit with weights, muzzles and sticks, and harnesses "used for weight training."

All of the dogs were found attached to chains that were tied to metal stakes in the ground. Inspectors also found anabolic steroids on site, according to court documents, and dogfighting contracts.

An inspector noted "that the majority of the adult dogs had severe scarring consistent with dog fighting. These scars were primarily located on the head, neck and forelimbs of the dogs."

Three of those dogs were immediately euthanized for medical reasons and the remaining 28 underwent a behavioural evaluation by the American SPCA, which said 21 of those dogs were deemed a menace to society and could not be rehabilitated.

The OSPCA, however, had to apply to court to have the dogs destroyed for behavioural reasons, which led to a public outcry.

Three animal organizations lined up to intervene in the OSPCA's application, with two going to court -- Dog Tales and Animal Justice, an animal rights organization -- which argued the dogs needed their own defence.

The judge denied those organizations' attempts to intervene last December.

In February, Dog Tales launched a publicity campaign, called .savethe21, which featured celebrity endorsements from Richard Branson, Enrique Iglesias and Paris Hilton, pleading with the OSPCA and the Crown to save the dogs.

Kenneth Marley, a defence lawyer who represents the three people accused of running the dogfighting ring, said he and Dog Tales pushed for a second behavioural assessment, since it had been about 18 months since the first one.

That assessment was a turning point in the case, according to Marley, Dog Tales and the OSPCA.

"That second assessment has shown some slight improvement as a direct result of our daily care and some promise to go to rehabilitation," said Jennifer Bluhm, deputy chief of the OSPCA.

One dog was deemed dangerous and the court ordered it to be euthanized.

Two other dogs died while in OSCPA custody.

According to the second assessment, which was submitted to court, Dog 10 "climbed over the wall of his own kennel, squeezed through a narrow opening, and then attacked and killed Dog 31 in her own kennel."

The assessment said Dog 10 has a very "guarded prognosis" for re-training, but will be shipped to Florida in an effort at rehabilitation.

Marley said the other dog that died in OSPCA custody was "euthanized on an emergency basis," but didn't have further details.

The OSPCA did not answer questions about the deaths of both dogs.

The majority of the dogs seized are taking twice-daily doses of fluoxetine, the active mood stabilizing agent in Prozac, according to the assessment.

Seven other dogs that were seized, as well as 11 puppies born after, will also be transferred to facilities in the United States.

Scheinberg said he will drive the dogs down to Florida himself in a modified bus.

"I think for most of them the future is a good one," he said.