"So if you smell something, say something," Mr. Stewart added.
And then, for good measure, there was a performance by Bruce Springsteen and the E Street Band.
The broadcast began with what appeared to be a traditional opening act in which Mr. Stewart poked fun at a current event — in this case, the Republican presidential debates in Cleveland. But this was simply a setup for the many on-air correspondents and contributors who have passed through "The Daily Show" during Mr. Stewart's time on the show to pay their final tributes.
Among the celebrated alumni who gave their testimonials, Steve Carell, who went on to become the star of NBC's "The Office" and films like "Foxcatcher," joked that he had never really left "The Daily Show."
"Becoming an international superstar is just something I did while waiting for my next assignment," Mr. Carell said.
Read More Jon Stewart, Sarcastic Critic of Politics and Media, Is Signing Off
Larry Wilmore, who now hosts his own Comedy Central late-night series, "The Nightly Show," groused that his program had been pre-empted this evening. "Black shows matter, Jon," he said to Mr. Stewart.
There were further cameos from John Oliver, Kristen Schaal and Samantha Bee, as well as Mr. Stewart's "Daily Show" successor, Trevor Noah, who wandered onto the set with a tape measure. ("Could you give me like 20 more minutes?" Mr. Stewart asked him.)
In a taped montage, several of Mr. Stewart's past targets of ridicule, including Chris Christie, Hillary Rodham Clinton, Bill O'Reilly and John Kerry, fired back good-natured ripostes at him. "So long, jackass," John McCain declared at the end of the segment.
And of course there was a visit from Stephen Colbert, the former "Daily Show" correspondent and star of Comedy Central's "Colbert Report," who is about to succeed David Letterman as the host of CBS's "Late Show."
In a sincere and seemingly unscripted speech, Mr. Colbert told Mr. Stewart that, though Mr. Stewart had previously told his staff members "never to thank you because we owe you nothing," this was "one of the few times I have known you to be dead wrong."
"You were infuriatingly good at your job," Mr. Colbert told Mr. Stewart. "All of us who were lucky enough to work with you for 16 years are better at our jobs because we got to watch you do yours."
Mr. Stewart first disclosed on a "Daily Show" broadcast in February that he intended to leave the program. "This show doesn't deserve an even slightly restless host, and neither do you," he said at the time.
Read MoreJon Stewart's 'Daily Show' departure stings Viacom
Since then, Mr. Stewart, whose handful of extracurricular activities include writing and directing the 2014 drama "Rosewater," has kept relatively quiet about his future plans, except to say that he intends to spend more time with his family. (On an official "Daily Show" podcast that billed itself as the "exclusive, definitive Jon Stewart exit interview," the host spoke mostly about the catered meals he and his staff ate on the program.)
In his final weeks in the anchor chair, Mr. Stewart largely resisted any impulses toward self-congratulation or gauzy nostalgia: Most nights found him inveighing against favorite nemeses, like the Koch brothers or his critics at the Fox News Channel. He played a few retrospective montages that emphasized his shortcomings, spotlighting awkward highlights from his celebrity interviews, his dissonant singing voice and his inability to make an impact on news events.
None of this discouraged some of Mr. Stewart's final guests from pleading with him to stick around a little longer. When President Obama appeared on "The Daily Show" in July, he jokingly told Mr. Stewart: "I'm issuing a new executive order that Jon Stewart cannot leave the show. It's being challenged in the courts."
While interviewing his friend and fellow comedian Denis Leary on Wednesday, Mr. Stewart said he was comfortable with his decision to step down.
"When you do something that you know you will never be as good at something as you were at this, you have to make peace with it," Mr. Stewart said. "And I've made peace with it."
In his final remarks to his audience, Mr. Stewart thanked his wife and children "for teaching me what joy looks like," and told his viewers that he was not leaving their lives for good.
"Nothing ends," Mr. Stewart said. "It's just a continuation. It's a pause in the conversation. So rather than saying goodbye or good night, I'm just going to say: I'm going to go get a drink. And I'm sure I'll see you guys before I leave."