His announcement Thursday comes just two months after Jay Leno left NBC’s “Tonight” show, and means that by next year the coveted 11:35 p.m. time slot on three broadcast networks will have a new lineup of hosts, skewing considerably younger. Jimmy Fallon, 39, replaced the 63-year-old Mr. Leno, and last year Jimmy Kimmel, 46, moved his ABC show from midnight to 11:35.

Speculation about Mr. Letterman’s successor will now become a popular parlor game for countless television executives, entertainment writers and late-night fans. Two choices mentioned frequently on Thursday by people at CBS and other networks: Stephen Colbert, the host of Comedy Central’s late-night show, “The Colbert Report,” and Neil Patrick Harris, the star of the recently concluded CBS comedy hit “How I Met Your Mother,” who has scored as host of awards shows on CBS.

Craig Ferguson, who hosts the 12:35 a.m. show on CBS, has also been mentioned as a contender. One executive who has been involved in discussions of CBS’s future in late night said the network would like to move relatively quickly to name a successor.

In his statement on the air, Mr. Letterman said he and Mr. Moonves had spoken several times about how his retirement would be handled. “We agreed that we would work together on this circumstance and the timing of this circumstance,” Mr. 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.’ ”

Mr. Letterman also thanked his staff and the viewers for supporting him during his run. He began the “Late Show” on CBS in 1993 after an 11-year run on NBC’s “Late Night” program, which he created. That total of 33 years in late night (counting 2015) eclipses the 30-year tenure of Johnny Carson on NBC’s “Tonight” show. (Mr. Letterman also hosted a morning show for four months on NBC, and in total he will have been the host of over 6,000 hours of television by the time he concludes his tenure on CBS.)