As far as big finishes go, the “Rockin’ in the Free World” finale Pearl Jam and friends stamped on their epic New Orleans Jazz and Heritage Festival set Saturday evening ranks as one of the biggest in recent festival history.

The Red Hot Chili Peppers’ Chad Smith gleefully thrashed away on drums while bandmate Josh Klinghoffer helped out on guitar, 24 hours ahead of their own band’s Acura Stage appearance. Pearl Jam’s Matt Cameron, liberated from his drum kit, took a turn out front on guitar.

Kings of Leon’s Nathan Followill was on tambourine, a job for which he was “over-qualified,” Pearl Jam frontman Eddie Vedder noted. A gaggle of kids danced in the wings. Avant-garde saxophonist Skerik blew a solo.

All the while, Steve Gleason, the Saints hero rendered immobile by Lou Gehrig’s disease, smiled broadly from the confines of his motorized wheelchair. Pearl Jam guitarist Mike McCready laid his head on Gleason’s shoulder, mouthing the chorus his buddy couldn’t.

In total, it was a gloriously messy, gloriously euphoric moment of rock ’n’ roll excess, cut with a bit of poignancy. Much like the two hours that preceded it.

Pearl Jam has a history with Jazz Fest. The band first performed at the festival in 2010. Vedder was booked to return two years later with his solo ukulele tour but canceled after injuring his arm.

Pearl Jam arrived at the Fair Grounds this weekend on the heels of various upheavals. The band canceled a recent North Carolina concert in protest of that state’s passage of legislation viewed by many in the LGBT community and beyond as legalized discrimination.

Gazing out at the vast — but not Elton John-scale vast — crowd filling the Acura Stage field on a sun-splashed Saturday, Vedder said, “It’s very colorful out there. It’s nice to come to a place where they don’t just tolerate people being colorful and themselves — they celebrate it.”

The most colorful people, he continued, can be found in jail at 4 a.m., a reference to his arrest after a night of revelry on Decatur Street in the early 1990s.

Prince’s death two days earlier triggered “reflection,” Vedder said. Rather than cover a Prince song, though, Pearl Jam played one of their own hits, “Even Flow,” that Prince had covered with his band 3rdEyeGirl.

“We were selfishly very honored,” Vedder said of Prince’s version. “He played the (stuff) out of it. We’re going to try to play the (stuff) out of it.”

McCready, especially, obliged, working his guitar behind his head, riffing an extended, spitfire solo, tearing at his effects pedals to produce squalls of feedback.

“Even Flow” was an early highlight of a two-hour and 15-minute set, the longest allotted time of the entire festival. In such a long set, peaks and valleys are to be expected.

Gleason, a longtime friend of the band, introduced Pearl Jam via his computerized voice synthesizer, just as he did at the 2013 Voodoo Experience in City Park. Vedder, McCready and bassist Jeff Ament sported “Defend Team Gleason” T-shirts.

The band opened fast and furious with “State of Love and Trust” and a brace of punkish rave-ups topped by Vedder’s scalded wail, but a long stretch of lesser-known, latter-day songs and ballads bogged down the set around the one-hour mark.

Gleason reportedly wrote out the set list for that Voodoo show; he likely wouldn’t have allowed such a challenging stretch this time, especially in a festival setting.

Pearl Jam’s current tour has been marked by “encores” that are nearly as long as the regular set. At 5:50 p.m., with more than an hour left on the Jazz Fest clock, they briefly disappeared.

Vedder had just gone down front to sing directly to the folks behind the VIP barricades; he literally hurled himself back onto the stage.

They returned to open the “encore” portion with a furious “Go.” From there on, the setlist was lean, the asides emotional. Vedder held up a Gleason Saints jersey and recommended the documentary “Gleason,” which depicts his struggle and triumph in the face of extreme physical adversity. “It’s a life-changer to see it,” Vedder said.

At the side of the stage, Gleason’s wife, Michel, lifted her husband’s right hand for a high-five.

With that, sunburst guitar chords heralded the majestic “Inside Job.”

“Searching hope, I’m shown the way to run straight,” Vedder sang. “Pursuing the greater way for all human light/How I choose to feel is how I am.”

As “Given to Fly” burst into full bloom, a skywriter high above the stage spelled out “PRINCE 1999” against the brilliant blue sky.

Vedder thanked fans for giving him and his bandmates “the best jobs on the planet. The jobs we had just before that job were not the best jobs on the planet.” Illustrating the point, he said, “Mr. Vedder, cleanup on aisle four.”

One reason he was able to leave such jobs behind was the early support of the Red Hot Chili Peppers, who took the up-and-coming Pearl Jam on the road as an opening act.

With the Chili Peppers set to play the Acura Stage on Sunday, Vedder said, “I feel like we’re back in an exciting position of opening for the Red Hot Chili Peppers. I don’t know where we’d be without their support. I can’t wait for tomorrow night.”

He said it felt “really bad” to be playing at the same time Van Morrison was on the Gentilly Stage, and he sympathized with Beck, who is scheduled simultaneously with Stevie Wonder at Jazz Fest next Saturday: “I know it’s eating him up.”

“Better Man,” a song Vedder wrote “back working at the drugstore,” was the sort of triumph that was missing early in the set. The singer, caught up in the moment, windmilled his guitar a la Pete Townshend.

In keeping with the theme, Vedder called out local trombonist “Big” Sam Williams, trumpeter Andrew Baham, tromobonist Carly Meyers and Skerik to goose a cover of The Who anthem “The Real Me.” Pearl Jam’s early smash “Alive” was just as big.

But nothing was as huge as “Rockin’ in the Free World.” When it crashed to a close, Vedder bade farewell with, “Thanks for the energy. I’ll keep it.”

At that point, there was plenty to go around.

Follow Keith Spera on Twitter, @KeithSpera.