“There were other lyricists involved in the writing of the Grateful Dead canon,” he wrote in the foreword to “The Complete Annotated Grateful Dead Lyrics” (2005; annotations by David Dodd). “Had I not joined, by invitation, as lyricist in residence, a year after they chose the name and nailed down the job through sheer prolixity, the band would have developed differently. It might have been less odd and more popular, for one thing.”

Mr. Hunter first met Jerry Garcia, the singer and guitarist who would become the band’s most recognizable member, in Palo Alto, Calif., when the two were still teenagers. They found that they shared an interest in music and even played together a bit.

“Our first group was Bob and Jerry, and our first gig was at Stanford,” he told Rolling Stone in 2015. “We got $5 for both of us. We kept it for a couple of days until we needed cigarettes, and then that was that.”

Mr. Garcia, Ron McKernan, Bob Weir, Phil Lesh and Bill Kreutzmann formed the Grateful Dead in 1965 (after briefly calling themselves the Warlocks). Mr. Hunter was in New Mexico when he was invited to join the party a year or so later.

“I had written ‘St. Stephen’ and ‘China Cat Sunflower,’” Mr. Hunter said, naming some early songs, “and I sent those — and ‘Alligator’ — off to Jerry, and he uncharacteristically wrote back. He said they were going to use the songs and why didn’t I come out and be their lyricist?”

Sometimes he would put lyrics to riffs the band was trying out. He came up with the lyrics for “Uncle John’s Band” after listening to a long instrumental tape over and over.