As the No. 1 late-night show for most of the past half-century, “The Tonight Show” has been vital to NBC’s fortunes. It was the network’s most profitable entertainment program during its 1990s peak, kicking an estimated $100 million to the bottom line annually.

And today? “Tonight” is in trouble. This month, the show saw wide layoffs for only the second time in its 58-year history, with about 20 people losing their jobs and host Jay Leno taking a pay cut that lopped off more than 10% from his estimated $26-million annual salary.

Leno even offered to work for free to save more jobs, according to people familiar with the matter, who said the offer was rejected because executives believed it would set a bad precedent. These people said “Tonight” was now barely breaking even.

PHOTOS: From Steve Allen to Conan O’Brien: Classic ‘Tonight Show’ moments

“A few years ago, ‘Tonight’ was like this reliable ATM for NBC,” Tom Nunan, a former NBC executive who is now a film producer. “Not anymore.”

The rapid slide of “Tonight” is a tale of not just backstage bungles by NBC but also the instability afflicting the TV business in general. And plenty is at stake. Cable networks devour nearly 84% of the $5.6-billion late-night TV market, according to research firm Kantar Media. And broadcasters’ share of the pie is steadily eroding, slipping 5% last year alone.

The stakes are getting even higher, with ABC’s announcement last week that it would schedule the increasingly popular “Jimmy Kimmel Live” a half-hour earlier, in the 11:35 p.m. slot directly opposite Leno and CBS’ “Late Show With David Letterman.” With both Kimmel and Leno based in Los Angeles (Letterman is in New York), the rivalry for guests as well as viewers is likely to be intense.

PHOTOS: TV axings and exits

“Tonight” has shed nearly one-third of its audience since mid-2009, when Conan O’Brien took over for Leno as host. O’Brien’s tenure lasted not even eight months after local station managers complained about his low ratings.

That led to a series of ill-fated maneuvers by NBC, then owned by General Electric (the company has since been purchased by cable giant Comcast). Reinstalling Leno — who had been given a 10 p.m. weeknight show that quickly flopped — led to scathing publicity and O’Brien’s departure to a rival show on TBS. Currently, “Tonight” draws about 3.7 million total viewers per night.

That’s still enough to make “Tonight” the No. 1 late-night show, but it’s a far cry from the 5 million or more viewers who tuned in before the ill-fated shift. Indeed, Leno is barely ahead of the 3.3 million or so notched by his longtime rival Letterman, one reason many analysts now consider NBC’s musical chairs one of late night’s biggest disasters.

“Jay has brought back some of his audience, but it’s not as robust as it once was,” Nunan said.

But dubious strategic and PR moves are only part of the problem. The competition in late night TV — for nearly three decades a fringe outpost ruled by Johnny Carson, Leno’s predecessor — is multiplying faster than “Tonight” can keep up.

There’s also a massive generational shift underway. “Tonight” is facing tough competition from Comedy Central’s Jon Stewart and Stephen Colbert, who draw much younger audiences and offer more pointed takes on the day’s headlines.

Ratings show that Leno, 62, is losing his grip on the young adults advertisers seek. Stewart’s “The Daily Show” has a median viewer age of 43 compared with “Tonight’s” 58 (by comparison, CBS’ newsmagazine “60 Minutes,” one of the oldest-skewing shows in prime time, has a median viewer age of 61). And “Daily Show” draws more adults aged 18 to 49 — the demographic most sought by advertisers — than Leno does. “The Colbert Report” looks poised to leap past “Tonight” by that measure soon.

“Guys like Jon Stewart, Colbert and even [Jimmy] Fallon have changed the standards of late-night comedy, even if their numbers aren’t as high as the old guys’,” said Robert Thompson, professor and director of the Bleier Center for Television and Popular Culture at Syracuse University.

An NBC spokeswoman declined to comment on the record and said that Leno would not be available.

Leno’s contract is set to expire in September 2013. NBC could decide to boot him and replace him as “Tonight” host with Fallon, who at 37 is young enough to be Leno’s son.

But such a switch might prove too much, too soon for NBC, given what happened the last time it tried to change “Tonight” hosts. The network is also facing enormous challenges elsewhere on its schedule; last year’s prime-time lineup tanked and ABC’s “Good Morning America” has pulled even with “Today.”

“The baggage of the Conan affair has never been fully unloaded,” said Jeffrey McCall, a professor of communications at DePauw University.

What is certain is that NBC will have to stay up late figuring out the best way to stay competitive in a time period it virtually invented with “Tonight.” That’s especially true with Kimmel, who is 44, due to get his promotion to 11:35 early next year. Kimmel is in third place with 1.8 million viewers, according to Nielsen, but that lower figure is partly explained by his midnight start. What’s more, he has been gradually gaining viewers.

“Kimmel’s climbing numbers demonstrate that late-night network comedy is still viable,” Thompson said.

Back when Carson ruled the slot like a personal fiefdom, the battle wasn’t so complicated. “It was a lonely, depopulated universe,” Nunan said.

“But look at it now. It’s staggering, the competition in late night. It’s like prime time.”

scott.collins@latimes.com

Times staff writer Joe Flint contributed to this report

PHOTOS, VIDEO AND MORE: