MADEIRA BEACH — What if a dog is a woman's best friend, but also a man's best friend?

She adopted the black Labrador retriever mix, but he paid for the vet bills.

At the end of the day, who is the rightful owner of 4-year-old Elario?

It's a question that a Pinellas County judge recently pondered in small claims court.

The plaintiff was David Somerville, a Vietnam War veteran recovering from lung cancer who credits the dog with improving his health.

The defendant is his neighbor Tina Marie Walker, a 53-year-old woman who has owned Labrador retrievers her entire life and spent $5 to adopt Elario even though he was emaciated and suffering from kennel cough.

Judge Lorraine Kelly's answer: Walker and Somerville must share custody, like divorced parents. She even created a calendar detailing pickup times.

"Both parties have spent a great deal of time with the dog," Kelly wrote in her order. "Witnesses say he shows great affection to both of his humans."

• • •

The story of Elario and his two owners began Jan. 7, 2016, according to court records.

Walker asked Somerville, 68, for a ride to the Pinellas County Animal Services shelter on Ulmerton Road.

She wandered through the hallways lined with cages, making her way to the quarantine section. She peered into the second cage on the left.

Inside was Elario, a black Labrador with honey brown eyes. His name, she learned later with a Google search, means joy.

On visits to Somerville's apartment, she brought her new companion along. Her neighbor grew close to Elario, taking him on walks while she worked part-time jobs at a cafe and a restaurant.

For two years, the 100-pound Labrador sauntered between their apartments.

But a rift soon formed between the neighbors.

What went wrong, court records show, depends on whom you ask.

• • •

This is Walker's version:

Months before the trip to the shelter, Somerville underwent lung surgery. His son asked Walker to keep an eye on him. She lived right across the hall at their Bayshore Drive apartment building facing the Intracoastal Waterway.

"We spent a lot of time together to the point where I stopped even having food in my apartment," she wrote in court records. "We did our shopping together, shared meals daily."

When she adopted Elario, she started taking him to Somerville's apartment.

But something went awry when Walker went on vacation to Martha's Vineyard last year and left Elario with Somerville. A few months later, in November, Somerville said he wanted to adopt him.

Walker offered to add his name to Elario's microchip.

On Dec. 22, Somerville sued Walker in Pinellas County court. He wanted to be Elario's sole owner.

"This dog is everything to me," Walker told the Tampa Bay Times. "I was only trying to share my joy with someone who needed it."

• • •

Somerville could not be reached for comment for this report, but this is what he told the judge in court records:

He walks Elario up to three times a day and takes him to the dog park in the evenings. When Elario cut his paw on a barnacle or needed a cyst removed, Somerville took him to the vet and handled the bills.

The animosity between him and Walker began when Somerville wanted Elario's microchip printed with his name since, he said in court, he is more "financially stable" than Walker.

That's when Walker, he says, started to keep Elario away from him.

"He does not get to see his dog friends at the park anymore," Somerville wrote. "He does not understand why when he sees me, he can't come to me."

• • •

On a recent afternoon, Walker sat on a bench in a dog park next to the Madeira Beach Recreation Department. Elario was sprawled by her feet, chewing on a tennis ball.

"I love my dog," she said, wiping away tears as she glanced at the court papers on her lap. "It's all I have in my whole life."

She has appealed and moved from the apartment building to avoid any more friction with Somerville. To this day, she says, Walker doesn't understand exactly what happened between them.

Elario barked and ran in circles around her. He grew still as Walker picked up his soggy tennis ball. He bolted after it when she tossed it across the grass.

The next day, she would have to drop him off at Somerville's apartment.

Contact Laura C. Morel at lmorel@tampabay.com. Follow @lauracmorel.