More than four years after Oreo went missing from his Palo Alto yard, the Boston terrier is home again.

Oreo’s owners and the Peninsula Humane Society are crediting the improbable reunion to a microchip implanted under his skin. The device was encoded with his family’s contact information.

“To get a dog back that you thought was gone for good is pretty crazy,” said Brandon Springer, adding that Oreo belonged to his grandmother, Ann Guglielmelli, who died last May.

“It shows that it does work.”

A humane officer found the black-and-white dog wandering near Security Public Storage in Daly City on Tuesday, noticed he had a leg injury and immediately brought him to the humane society’s San Mateo shelter.

The microchip was detected during a subsequent exam, said Scott Delucchi, a spokesman for the humane society.

“This story illustrates the importance of microchips, which can be a lost pet’s ticket home,” Delucchi said.

At just $30, the devices are affordable and can be implanted without an appointment, he added.

“Too many people don’t know how inexpensive this can be and how easy of a process it is,” Delucchi said. “Hopefully, this happy ending will cause more people to consider this permanent form of identification for their pets.”

Oreo escaped from his yard four and a half years ago when a gate was left open, Springer said. His owners believe he ran to nearby Cubberley Community Center, where he went for walks, and was scooped up by a spectator at a soccer tournament happening there that day.

The family posted signs around the neighborhood and checked shelters, but eventually lost hope that they would ever find Oreo.

When Oreo was found Tuesday, he appeared to be in good health despite a dislocated hip and a broken knee cap. A veterinarian at Alta View Animal Hospital in Mountain View told Springer that Oreo was disease-free, which indicates he was cared for over the past couple of years.

Oreo’s injuries were likely the result of being hit by a car in the past two or three months, but it’s also possible he was abused, Springer said.

Fortunately, the prognosis for Oreo is good. He should make a complete recovery following a $2,000 surgery, Springer said.

“He’s doing well,” Springer added. “He’s obviously in a little bit of shock, but he’s happy.”

The reunion has been bittersweet because of his grandmother’s death last year, Springer said. But his grandfather, Larry, took a picture of her when he went to see Oreo at Alta View.

“He was stoked,” said Springer. “He said, ‘That’s my dog. I’m taking him home!'”

Email Jason Green at jgreen@dailynewsgroup.com; follow him at twitter.com/jgreendailynews.