A retired cop whose beloved K-9 partner was set to be sold at auction can now rest easy.

Matt Hickey, who retired from the police force in Marietta, Ohio, last week, was able to purchase his police dog, Ajax, from the department for $1, he confirmed to The Huffington Post.

For the past week, Hickey had been afraid he’d be separated from his canine companion forever -- a situation that would be devastating for both man and dog. The two had been police partners for three years, and had developed a deep professional and personal relationship.

“He’s with me 24/7,” Hickey said on Wednesday. “He goes with me on my vacation; there’s a tight bond. I’m his pack leader.”

The fate of Ajax had been up in the air because, at age 5, he was too young for police dog retirement. Hickey offered to purchase Ajax for $3,500 -- a value set by the city. But Marietta officials said an Ohio state law seemed to forbid Hickey from purchasing Ajax. They decided they would sell Ajax at an auction that invited former police officers and K-9 handlers to bid.

“The dog is property of the city of Marietta,” Paul Bertram III, the city law director, told news station WBNS last week. “Because it is personal property, it is treated like a shovel. That's just the way it is.”

The story prompted a national outcry, with social media attacks on the police department and the city. Marietta resident Corey Orr set up a GoFundMe account -- which raised more than $70,000 -- meant to help Hickey purchase Ajax at auction if it came to that.

On Monday, Marietta Police Chief Rodney Hupp held a news conference and proposed a solution that would involve Hickey working as an unpaid auxiliary officer in order to legally keep Ajax. But Hickey declined the position due to health issues.

UPDATE: Retired OH cop declines auxiliary position that would allow him to keep K9 partner: https://t.co/ocT5X7VQyY pic.twitter.com/4i1Deze4Ok — WTHR.com (@WTHRcom) February 3, 2016

Thursday afternoon, however, Hickey got some amazing news. Bertram, the law director, called him and told him he’d be able to purchase Ajax for $1.

Why the apparent change of heart? Bertram told local news station NBC 4 the agreement hinged on a state law’s definition of the term “canine unit.” Ohio law says that if a “canine unit” is “disbanded,” a dog’s handler can purchase the animal for $1. That section of Ohio code doesn’t actually define “canine unit,” but Bertram found that in the Ohio Administrative Code, “canine unit” means “a canine handler who shall be a sworn law enforcement officer and a canine.”

In other words, Hickey's retirement meant that the “unit” -- consisting of him and Ajax -- was disbanding, which legally allowed him to buy Ajax for a dollar.

Hickey, who said he believes city officials misread the law initially, said he's grateful for the enormous public support he and Ajax received.

“I didn’t know there were this many people that were that good,” he said, explaining that after 34 years on the police force, he'd become somewhat jaded.

“It’s hard to put into words how much I want to thank everybody," he added.

But keeping Ajax doesn’t mean Hickey's work is done. He’s talking with state legislators about a bill to make sure that no officer -- and no police dog -- has to go through what he did.

The money raised through the GoFundMe account will be donated to Vested Interest in K9s, a charity that provides bulletproof vests for police dogs.

As for Ajax? He never knew he was at the center of such a heated controversy. But Hickey said the dog seemed to pick up on the stress of his owner, and as a result was acting anxious himself.

“He’s more relaxed today,” Hickey said.

Also on HuffPost:

PHOTO GALLERY Police Dogs In Action