A 128-year-old painting of a Vineyard sheriff has been rehung in the Edgartown courthouse after extensive restoration. The painting of Sheriff Frances Cottle Smith was accidentally slashed from behind while in storage when the courtroom was repainted four years ago.

And behind an oil painting with an accidental slash lies an intricate family story.

The restoration work was spearheaded by Ann A. Perkins — a Los Angeles resident who is the great-great-granddaughter of the subject in the portrait — and her husband, John.

Capt. Cottle Smith was elected Dukes County sheriff in 1873; he later retired to New Bedford where he died in 1911 at the age of 96.

Before that he had traveled the world on a whaleship. He went around Cape Horn eleven times, Cape Good Hope seven times and around the world three times. “To us he was always known as Captain Frank,” Mrs. Perkins said.

“We have another picture of him that has been in the family for generations, of him standing with four other whaling captains. It appeared in a newspaper and was taken near the end of the Civil War,” she said. Captain Smith had been aboard a whaling ship that was attacked by the Confederate ship Shenandoah in the Pacific. All five captains and their ships had been captured by the Shenandoah.

The captain’s ship, William Thompson, was burned and sunk and he was taken prisoner.

When he left the sea, he settled back on the Vineyard to go into real estate. He was elected sheriff the same year the jail was built, according to Sheriff Michael McCormack, who participated in the re-hanging of the portrait last month.

Ian Primrose, a painting restorer in Falmouth, did the work on the painting, with support from the Martha’s Vineyard Museum and the county which maintains the courthouse. He said the painting was done by Nahum Ball Onthank in 1883, a Boston portrait painter who did a lot of work in southern New England. “I saw that painting on a daily basis from January until [last month],” he said. He said most of the work involved saving the canvas, repairing the tear and flattening the surface. In addition, he cleaned the painting, which brought out the signature of the artist and brightened the work.

His other work includes restoration of a painting of the whale ship Niantic, which belonged to the family of Dionis Coffin Riggs of West Tisbury and was gifted to the San Francisco Maritime Museum in 2010.

For Mrs. Perkins, the painting was part of a family journey. “We were on the Vineyard four years ago, searching archives for more family information. We went to the registry of deeds and were lolling around,” she said. They went upstairs to the courtroom and eventually found the torn painting that had been set aside in a room.

The Perkins family donated $8,000 to the project; $4,000 was for the painting restoration and the rest will be used to underwrite an educational program for Island high school students administered by the museum.

The painting now hangs where it did before the accident, in the southwest corner of the courtroom.