NEW YORK (AP) — David Letterman’s departure from the late-night realm won’t just end an unmatched run on television. It also will close the book on an era reaching almost to the birth of TV.

During a taping of Thursday’s edition of “Late Show,” Letterman startled his audience with the news that he will step down in 2015, when his current contract with CBS expires.

He specified no end date, saying he expects his exit will be in “at least a year or so, but sometime in the not too distant future — 2015, for the love of God, (band leader) Paul (Shaffer) and I will be wrapping things up.”

What he’ll be wrapping up is three decades on the air — the longest tenure of any late-night talk show host in U.S. television history — since he launched “Late Night” at NBC in 1982.

But more than that, he’ll be ending a lineage of late-night hosts who pioneered talk and humor in the wee hours — Johnny Carson, of course, and, before him, Jack Paar and especially Steve Allen.

Ironically, they were all on NBC, the network that denied Letterman the “Tonight Show” crown he sought and, after he lost out to Jay Leno, prompted him to pitch his tent at CBS as Leno’s rival.

Referring to CBS chairman Leslie Moonves as “the man who owns this network,” Letterman told viewers Thursday, “I phoned him just before the program, and I said, ‘Leslie, it’s been great, you’ve been great, and the network has been great, but I’m retiring.'”

Since premiering with “Late Show” in 1993, Letterman, who turns 67 next week, has reigned at Broadway’s Ed Sullivan Theater, a historic venue nearly a century old that was famously home to “The Ed Sullivan Show.”

The Los Angeles-based Leno, 63, retired from “The Tonight Show” this year, clearing the way, not by his choice, for “Late Night” host Jimmy Fallon to move up to that TV institution.

“For 21 years, David Letterman has graced our network’s air in late night with wit, gravitas and brilliance unique in the history of our medium,” Moonves said. “It’s going to be tough to say goodbye.”

Letterman, who was a radio talk show host and local TV weatherman, moved to Los Angeles in the 1970s and, among his early gigs, was a writer and performer on a summer variety show and a member of the comedy troupe of a short-lived program starring Mary Tyler Moore.

In 1980, he hosted an NBC morning show, which lasted only five months — while winning two Emmy awards.

Two years after that, he was turned loose with “Late Night,” where he clicked.

A generation later, Letterman will leave with an unparalleled comic legacy of weirdness, laser-focused sarcasm and an ironic sensibility that saturated the culture. (“Letterman-esque” may not be in any dictionary, but his fans know what it means.)

Meanwhile, the famously private Letterman, a true product of his Midwest upbringing, gave the world an occasional glimpse into his inner life in ways that were as notable for their intensity as they were for their rareness.

Viewers will never forget the real-life drama surrounding his quintuple heart bypass and his triumphant return to the air in February 2000, when he brought onstage the doctors and nurses who had saved him. He was nearly in tears as he thanked them.

A week after the Sept. 11 attacks, he delivered a riveting, from-the-heart monologue, connecting with his viewers in their shared mourning and disbelief.

And in 2009, he stunned his audience with a confession that he, a married man, had had sexual relationships with several of his female employees and had been the victim of an extortion attempt he helped derail by working with police on a sting. What could have been a career-ending scandal displayed him, in yet a new way, as a master at controlling his message.

Leno held the ratings leadership for most of the two-decade duel with Letterman.

But Letterman remained the overwhelming critical favorite. He earned a Peabody Award in 1992 and a Kennedy Center Honor in 2012. “Late Show” won a prime-time Emmy in 1994, one of several showered on his programs through the years.

In an interview with Howard Stern in January, Letterman declared that Leno’s departure would have no impact on how much longer he might stay as “Late Show” host.

“I would do it forever if it were up to me,” said Letterman, before adding a wry aside: “Sometimes, it isn’t up to me.”

But now, with the late-night dust settling at NBC, Who Replaces Letterman becomes the new guessing game. In the wings as a prospective heir: Craig Ferguson, host of “The Late Late Show,” which has followed Letterman, who produces it, since 2005.

It’s a vastly different late-night world than when Letterman burst on the scene at age 34 or even when the Leno-Letterman Late Night War erupted. Not only is late night now replete with talk-show choices, but the way TV can most effectively be packaged in the digital age seems to demand new skills from its upcoming generation of hosts.

But that doesn’t mean Letterman won’t be missed, not unlike the way Carson is still missed by many viewers decades after he retired.

Syndicated late-night host Arsenio Hall said Thursday that CBS might be able to fill Letterman’s time slot, “but it can never fill the void he will leave behind.”

ABC host Jimmy Kimmel tweeted that Letterman “is the best there is and ever was.”

And everyone was suddenly put on notice: Only a year or so of Letterman to go.

Ericka Conley