There’s no shame in playing the hits when the hits are as iconic as the ones Tom Petty made throughout four decades. As recently as the last week of September, social feeds lit up with ­exhilarating footage from the Hollywood Bowl, where Petty and The Heartbreakers ­concluded their 40th-anniversary tour with three shows stacked with classics like “Refugee,” “Free Fallin,’ ” “Mary Jane’s Last Dance” and “Learning to Fly” -- all sleek hook machines that work as well now as when they were recorded. Petty knew he had one of rock’s all time greatest singles ­catalogs, and he made excellent use of it in 2017.

But those indelible choruses only tell part of Petty’s story. His ability to write that way, with a seemingly effortless elegance unlike any of his peers, was grounded in his deep knowledge of rock history and his finely honed instrumental technique (paired with that of his bandmates, notably guitarist Mike Campbell and keyboardist Benmont Tench). You can hear it in the breadth and depth of The Live Anthology, the four-disc box set the band released in 2009. But better still, those who scored tickets to the group’s rare tours of smaller venues in recent years got to witness it in person.

On one such memorable run in 2013, the band made it through five nights at New York’s Beacon Theatre and six at Los Angeles’ Fonda Theatre without touching many of its best known songs. Instead, the group played fast, loose versions of little-heard jewels (“When the Time Comes,” from the 1978 album You’re Gonna Get It!, appeared for the first time in 33 years in New York) and a diverse array of covers. The setlists slid easily from Memphis soul (Booker T. & The MG’s’ “Green Onions”) to Chicago blues (Muddy Waters’ “I Just Want to Make Love to You”) to Tulsa roots-rock (J.J. Cale’s “I’d Like to Love You Baby”) to Nashville country (Conway Twitty’s “The Image of Me”) to California garage rock (The Monkees’ “[I’m Not Your] Steppin’ Stone”) -- brilliantly unraveling the tapestry of American sounds that Petty wove together starting in the 1970s.

Most surprising of all was how freely the group jammed at these shows. Performances of the Grateful Dead’s “Friend of the Devil” stretched to seven minutes or more, spinning out into wild, cosmic dances among Campbell’s guitar, Tench’s organ and Petty’s harmonica. This wasn’t a luxury the band often allowed itself on record, where its primary focus remained concise three- or four-minute pop songs, calibrated for maximum joy per second. It was revelatory to see how well the gambit worked in concert, showing off the sheer technical talent that made the group’s most popular records possible.

After seeing one of those shows, it was natural to ask why Petty didn’t do this more often. Perhaps he found it more fun as an occasional treat. More likely, by that point in his career, Petty would have liked to play such sets for larger audiences but felt it wouldn’t have been fair to the arena and ­amphitheater crowds who paid to hear their favorite radio hits. If Petty felt that tension, his dedication to giving millions of fans what they wanted won out. That’s a big part of what made Petty such a unique star: His was one of the least self-indulgent, most generous careers in rock. But put him in front of a smaller room of devoted listeners -- the people who wanted the deep cuts and the long jams he so loved to play -- and boy, could he deliver.

This article oiginally appeared in the Oct. 14 edition of Billboard.