David Letterman told Thursday's audience he plans to call it quits next year.

Correction: An earlier version of this article misstated the year Letterman began on NBC's Late Night.

David Letterman announced plans to retire next year on Thursday's Late Show.

The host, who has been on CBS since 1993, made the announcement to his studio audience at an afternoon taping, and was met with laughter, stunned disbelief and later, a standing ovation.

"The man who (runs) this network, Leslie Moonves, he and I have had a relationship for years and years and years, and we have had this conversation in the past, and we agreed that we would work together on this circumstance and the timing of this circumstance," Letterman said. "And 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.'"

He added: "I just want to reiterate my thanks for the support from the network, all of the people who have worked here, all of the people in the theater, all the people on the staff, everybody at home, thank you very much. What this means now, is that Paul and I can be married," he joked, in a reference to bandleader Paul Shaffer.

"We don't have the timetable for this precisely down — I think it will be at least a year or so, but sometime in the not too distant future, 2015 for the love of God, in fact, Paul and I will be wrapping things up," he added.

Letterman, 66, has been a TV fixture for 32 years and the longest-running TV host in late night, eclipsing Carson's 30-year run. He was the first host of NBC's Late Night, starting in 1982, but left when NBC passed him over for Jay Leno when Johnny Carson retired a decade later. In contrast to Leno, Letterman quickly established a reputation for edgier humor, a cynical eye and playful but probing interviews with politicians and celebrities, though he's now grown into a more curmudgeonly persona. An Indiana native, he started his career as a weatherman and was briefly a morning-show host on NBC.

Yet his late-night audience has faded in recent years as viewing habits changed, amid a generational shift of hosts. In the six weeks since Jimmy Fallon replaced Leno on NBC's Tonight Show, Fallon has averaged 5.2 million viewers, nearly twice as many as Letterman's 2.7 million, who in turn led ABC's Jimmy Kimmel, who moved to 11:35 last year, by just 50,000 viewers, according to Nielsen. Letterman finished dead last among adults ages 18 to 49, the sweet spot for advertisers, and was down in both measures from last year.

Once he leaves, the entire three-network lineup will have shifted to new hosts; Fallon is 39, and Kimmel is 46. (Kimmel, a fan, tweeted that Letterman "is the best there is and ever was." Fallon released a statement saying, "Dave's the greatest. One of the true innovators in TV history. He's made all of us better." )

Many industry watchers thought Letterman would wait to outlast Leno, but one person close to him insists that wasn't a motivating factor. His decision to retire is "not surprising at all," says TV historian Tim Brooks. "Why be the old gray beard, when Fallon and others are kind of remaking late night."

"There might be some degree of Letterman saying, 'I'm going to do this on my own terms, rather than the situation of Conan (O'Brien) and Jay," whose exits were more dramatic--and largely involuntary, says analyst Sam Armando at Chicago ad firm SMGx.

On May 20, 2015, David Letterman will sign off of "The Late Show with David Letterman" for the last time. We look back here on memorable moments in his television career. Jeffrey R. Staab, CBS

Tom Hanks surprises Julia Roberts and David Letterman when he drops by the the "Late Show." Letterman tested Roberts' knowledge of Hanks "Newlywed Game"-style, asking her questions about the actor. Heather Wines, CBS

Paul Shaffer helps David Letterman dole out pies in the face to Regis Philbin as Letterman and Philbin toss pies at each other in tribute to the passing of comedian Soupy Sales in October 2008. John Paul Filo, CBS

Johnny Carson in his first and only talk show appearance since stepping down as host of "The Tonight Show," gets a standing ovation by Letterman and the studio audience when he makes a surprise appearance on the "Late Show" on May, 13 1994. Tony Esparza, CBS

Letterman interviewed Paul McCartney and Ringo Starr for a CBS special 'The Beatles: The Night That Changed America - A Grammy Salute' in February 2014. Letterman's show is taped in the Ed Sullivan Theater in New York, the same theater where the Beatles made their American debut in 1964. Jeffrey R. Staab, CBS via AP

Letterman reacts as Madonna arrives on stage bearing Valentine's Day gifts in February 1995. Madonna dropped by Letterman's show to wish him a happy Valentine's Day and promised, "I'm not going to say (bleep) any more." It was the singer's first return to the show since her notorious March 31, 1994, appearance when she had to be bleeped by CBS censors a total of 13 times. Alan Singer, CBS

Letterman looks on as musical leader Paul Shaffer, center, bites into a fried baloney sandwich made by Dave's mom, Dorothy, left, in 1996. Dorothy was promoting her new cookbook, 'Home Cookin' with Dave's Mom.' Letterman said as a kid he'd have a fried baloney sandwich "every day, two or three times a day, especially when mom slept late." CBS via AP

Letterman gestures during his interview with Hillary Rodham Clinton in January 2000. She made her first visit to the show, a stop that follows weeks of the late-night host taking pot-shots at Clinton over her decision to relocate and her intention to run for U.S. Senate in New York. Barbara Nitke, CBS

Robin Williams laughs while exchanging heart surgery stories with Letterman in May 2009. It was Williams' first television appearance since his heart surgery eight weeks earlier. John Paul Filo, CBS via AP

One of the nightly features on the 'Late Show' was the 'Top Ten' list. Britney Spears presented the 'Top Ten Ways the Country Would Be Different if Britney Spears Were President' in August 2009. CBS via AP

In a highly personal and public moment in October 2009, Letterman talks about having had sexual relationships with female employees and how a CBS employee tried to extort $2 million from him over the affairs. CBS via AP

Like this topic? You may also like these photo galleries:

It's unclear how CBS will replace Letterman, and when, precisely. Letterman signed a one-year contract extension late last year that takes him to August 2015, though he could leave as early as May.

Craig Ferguson, who hosts the Letterman-produced Late Late Show, is not being considered as a replacement, insiders say, even though his contract technically promises it. Moonves is known to have been interested in The Daily Show's Jon Stewart over the years, but in the past Stewart has said he is not interested in a network talk show.

Stewart's Comedy Central partner Stephen Colbert is seen as a more likely candidate, and is available sooner: His contract with Comedy Central expires in December, though Stewart is free in 2015. Chelsea Handler announced plans to leave her late-night E! show this year, but Armando says her appeal may be too narrow. But "I'd be shocked if they don't try to get a (new) host who appeals to a younger audience," he says.

In a statement, Moonves graciously thanked Letterman: "When Dave decided on a one-year extension for his most recent contract, we knew this day was getting closer, but that doesn't make the moment any less poignant for us. 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. During that time, Dave has given television audiences thousands of hours of comedic entertainment, the sharpest interviews in late night, and brilliant moments of candor and perspective around national events. He's also managed to keep many celebrities, politicians and executives on their toes – including me. There is only one David Letterman. His greatness will always be remembered here, and he will certainly sit among the pantheon of this business. On a personal note, it's been a privilege to get to know Dave and to enjoy a terrific relationship. It's going to be tough to say goodbye. Fortunately, we won't have to do that for another year or so. Until then, we look forward to celebrating Dave's remarkable show and incredible talents."