Jim Nabors, a comic actor who found fame in the role of the amiable bumpkin Gomer Pyle in two hit television shows of the 1960s while pursuing a second career as a popular singer with a booming baritone voice, died on Thursday at his home in Honolulu. He was 87.

His husband, Stan Cadwallader, confirmed the death. He said that Mr. Nabors’s health had been declining for a year and that his immune system had been suppressed since he underwent a liver transplant in 1994.

At the time, Mr. Nabors announced that he had contracted hepatitis B in India several years earlier when he cut himself shaving with a contaminated straight razor, which he had bought there.

Gomer Pyle, the character that so indelibly stamped Mr. Nabors’s career, originated in 1962 as a supporting role on “The Andy Griffith Show,” a bucolic CBS comedy that had been running since 1960. Gomer was a guileless, sweet-natured gas-station attendant in Mayberry, N.C., a sleepy fictional town where Mr. Griffith played the widower sheriff, Don Knotts his deputy, Ron Howard his son and Frances Bavier his matronly Aunt Bee.