It was one of those happy accidents that’s become a tradition: Robert Earl Keen, struck with writer’s block, kicked back and strumming the guitar.

Little did he know that the ditty he came up with — “Merry Christmas from the Family” — would become not only one of his most beloved songs but a holiday staple for fans of country and Americana as well. And now it’s turned into the building block for a holiday-themed jamboree-style tour that Keen will bring to The Tennessee Theatre in downtown Knoxville on Friday night.

He still chuckles at the memory of writing it, and how it almost didn’t wind up on “Gringo Honeymoon,” his fourth album.

“I was trying to really be super smart and clever and poetic and all that business, just grinding myself to a halt, and it was right around this time of the year,” Keen told The Daily Times recently. “I was trying to write a serious record, and I was thinking I had all of December to write, but then I realized, ‘No I don’t — it’s Christmas time! I gotta finish this now!’ So I kind of leaned back on the couch and was strumming my guitar and thinking about how, growing up in Houston, there was nothing even remotely connected to Houston and a Christmas song.

“I wrote it as a way to blow out the cobwebs, and I got a huge kick out of it, just laughing my ass off the whole time I was writing it, but then I just put it away. I went to talk to the producer about making this record, and I played him all these songs, and he asked, ‘Got anything else?’ ‘Not really,’ I said. ‘Anything?’ ‘Well, I’ve got this stupid Christmas song,’ and I played it for him. And he said, ‘Man, that’s just brilliant,’ and he’s not the typical ass-kisser sort of producer; he’s a tough guy.”

That producer, Garry Velletri, urged Keen to include it on “Honeymoon,” but Keen was reticent, he said. However, back home in Texas (he was in Nashville when he wrote it — “I kind of squeezed the creativity between all the billions of antennas in Nashville and caught a breath of fresh air,” he joked), he played it live. The crowd lost its mind, and they’ve continued to do so ever since.

“I’m just kind of blinking, thinking, ‘Wow — this is what it’s like to be Loretta Lynn!’” he said. “It’s like a ‘Coal Miner’s Daughter’ story.”

Maybe — if Lynn had been raised in the rolling hills and cracked hardpan of Texas instead of the hollers of Kentucky. Keen started out as part of the Texas Movement, a wave of songwriters that included Steve Earle and Lyle Lovett who all emerged around the same time, drawing on earlier Texan influences such as Guy Clark and Townes Van Zandt to paint vivid, often painful portraits of life. In fact, Keen started out in the same Texas club scene as Lovett, but mainstream fame didn’t take to him like it did some of his peers. Along the way, however, a dedicated following began to sit up and take notice. Over a period of many years and 12 records, Keen detailed such gritty subjects as alcoholism, selfishness and murder, writing about the things that make many listeners squeamish — lovers changing their minds and then their paths, growing older and the expense of loyalty when “the sacrifice and compromise can’t stand the strain.”

It’s not always darkness where Keen is concerned, however. “Merry Christmas from the Family” is a portrait of a white-trash family reunion, but the scope of his work stretches far beyond that simple song. His songs have been recorded by a wide range of Americana artists, from his old friend Lovett to Nancy Griffith to Gillian Welch. And he’s recognized far beyond the cult circles in which he runs and draws fans — when country superstar George Strait decided to throw an all-star benefit for Texas residents affected by Hurricane Harvey earlier this year, Keen was one of the artists he called.

“Somebody called and said, ‘George is gonna send you a list, if you want to sing any songs,’ and I said, ‘I don’t want a list — I want to do “Amarillo by Morning” and “Oceanfront Property!”’” Keen said. “Lyle called me up the next day and said, ‘It seems like you were cherry-picking there!’ I just threw it out there, man. As far as the show goes, it was as close to perfection as any show I’ve ever been in. Everybody left their egos at the door, and we all had so much respect for George for doing it for all the right reasons. The only thing bad that happened was that Miranda (Lambert)’s bus hit George’s pickup truck!”

When those opportunities arise, Keen counts himself among the fortunate few — those artists who have never compromised their principles, who have stuck to their guns and who have carved out a career worthy of the songwriter label — yet, at the same time, have found respect and love from those who have chosen to go a more mainstream route. Not that fame has eluded him entirely — John Isley and Billy James, the hosts of the nationally syndicated “John Boy and Billy Big Show,” got ahold of “Merry Christmas from the Family” early on, and for a while there, the song overshadowed the rest of Keen’s catalog entirely.

“They played it over and over, and people would come to the show just to hear that song,” he said. “I’ve never had a real hit, a radio hit out there in the world of mainstream radio, but I’ve had friends who had that. And with this, I finally knew what it felt like to have that. I would play a show, and people would stand there with their arms crossed, looking at me like, ‘Prove something to me.’ And then we’d play that song, and they’d jump up and down and slap each other on the back and laugh and toast. It took a couple of years for it to sink in out there in the masses, but now it’s on Christmas playlists every year. It’s truly the gift that keeps on giving.”

And now it’s giving in new ways. Rebranded as “Merry Christmas from the Fam-O-Lee,” it’s been retooled as the centerpiece of an entire Christmas show. Since the song first caught fire, Keen has been keen to do a holiday show, and what better way, he said, than to have a raucous holiday hoedown?

“It’s altogether different; we have a huge Christmas set with an 8-foot can of fake snow and the world’s biggest box of tampons,” he said. “Every year is a theme. Last year was ‘Country Gold Jamboree,’ and we were really tempted to recreate that, because it was so fun and successful, but every year, part of the fun and the challenge is figuring out a way to present this show and coming up with a new theme. This year, it’s ‘Back to the Country,’ after Neil Young’s song. Everybody in the band dresses up as a country-rock icon — Neil, Tom Petty, Dwight Yoakam. We hit the high spots on our heavy rotation setlist that people want to hear — ‘Feelin’ Good Again,’ ‘The Road Goes On Forever’ — and we really put this show across.”

It’s a show that only comes around once a year; although Keen makes Knoxville a regular stop on his tours, this is the first time he’s brought the Christmas show here, but wherever he performs it, it’s always a good time. The first year he and the band put it on, he and the boys dressed up as Middle Eastern kings; the next year’s performance included a group of madrigal singers. They’ve hired actors to recite soliloquies from “A Christmas Carol,” and four years ago, they started introducing a theme to the performances. There’s even a good chance that the sequel to “Family” — “Happy Holidays Y’all,” from Keen’s 1998 record “Walking Distance” — might make an appearance.

“It’s kind of fun, even though it’s not nearly as good,” he said. “Everybody trades of instruments — I play bass, the fiddle player plays the drums, the steel guitar guy plays the fiddle, and it’s awful. It’s like the day in eighth grade band where the substitute comes in.”

“Merry Christmas from the Family” was recently re-released to radio, and one of Keen’s most popular records, “No. 2 Live Dinner,” was just given the vinyl treatment. He’s working on a “super secret project” for 2018 that he’s not at liberty to talk about, and he’s planning to get back into the studio as well. Lord willing, the waters won’t rise and Keen’s services won’t be needed for additional all-star benefits, but if they are, you can bet he’ll be right up there with the bigger names and the old friends. And, he added, the same thing will go through his mind then that went through it back in September, when he joined Strait, Lovett, Lambert and Chris Stapleton to close out that Hurricane Harvey show.

“When I’m in the middle of that stuff, I always ask — how long can this moment last?” Keen said.