NEW YORK (AP) _ Led by top-rated NBC's major audience gains in its historic victory season, network television finally halted its audience erosion to cable and independent stations for the first time since 1976-77.

Combined viewing on NBC, CBS and ABC increased 1.24 percent from 48.5 to 49.1 ratings points in 1985-86.

''We took audiences from the (network) competition, pay-cable and the independents,'' said Bill Rubens, NBC's vice president for research.

''About half of NBC's increased audience came from non-network viewers,'' said Dave Poltrack, CBS' vice president for research.

NBC's audience growth, which Poltrack called extraordinary, was 1.3 ratings points over last season, giving the network its first outright prime-time victory since the A.C. Nielsen Co. started counting eyeballs three decades ago. CBS had finished first the past six seasons.

According to Nielsen figures released Tuesday, NBC won the 30-week season that ended Sunday with a 17.5 rating, an increase of 8 percent. CBS fell from 16.9 to 16.7. ABC slipped from 15.4 to 14.9. (A single ratings point equals 859,000 homes with television.) NBC also led in every age group except adults over 55, which CBS still dominated.

''I've been waiting 6 1/2 years for this,'' Brandon Tartikoff, president of NBC Entertainment, said during a satellite hookup with television writers. Tartikoff joined NBC in 1980 and suffered third-rated seasons until the network jumped to second place last year.

Much of the credit goes to NBC's twin Thursday comedies, ''The Cosby Show'' and ''Family Ties,'' which finished one-two, replacing the soapy ''Dynasty'' and ''Dallas'' as television's most-watched series. The last two comedies to top the ratings were ''Laverne & Shirley'' and ''Three's Company'' in 1978-79.

The rest of this season's Top 10 included CBS' ''Murder, She Wrote'' in third, followed by CBS' ''60 Minutes,'' marking its seventh consecutive season in the first four, and NBC's ''Cheers.'' Next came CBS' ''Dallas,'' which reached the Top 10 for the seventh straight time, ABC's ''Dynasty,'' last season's No. 1 show, NBC's ''The Golden Girls,'' the top-rated new series, NBC's ''Miami Vice'' and ABC's ''Who's the Boss?''

This season, Poltrack said, the networks proved more adept at counter- program ming for available audiences. For example, while CBS' ''Falcon Crest'' was appealing to women viewers on Friday night, NBC found the disaffected male viewers with ''Miami Vice,'' producing two simultaneous hits, Poltrack noted.

A Nielsen study of homes with pay-cable's HBO in March showed that viewing was up for all three networks in those households but down for all other stations, incuding HBO and independent stations. NBC showed the greatest increase - 2.4 ratings points.

''In essence, each of the networks put on a better schedule than a year ago,'' said Gerald Jaffe, NBC's vice president for research projects.

Ratings for all three networks were up with those viewers earning more than $40,000 in income. ''Cable is not taking away our upscale viewer,'' Poltrack said. ''Cable is taking away some of our heavy television viewer,'' which he described as more middle class, earning about $20,000 a year.

The networks also improved their performance with adults 18-49, the favorite group of most advertisers. ''In that respect you'd have to say it was a good year,'' said John Sisk, senior vice president of the J. Walter Thompson ad agency.

One program that crossed all lines was ''The Cosby Show,'' which ranked No. 1 in every age group except adults over 50. It averaged a 33.7 household rating, the best performance for any series since ''Dallas'' in 1980-81 and the best for any sitcom since ''All in the Family'' in 1971-72. On average, 28.9 million homes were tuned to each episode of ''Cosby.''

''Cosby'' and ''The Golden Girls'' gave NBC two winning comedy-backed nights on Thursday and Saturday. NBC finished second every other night. ''A lot of NBC's strength was in its ability not to finish third,'' Poltrack said.

ABC fell to third for the second straight season because its progams fared so poorly on Thursday, Friday and Saturday. But ABC improved in the second half of the season with its ''Disney Movie'' on Sunday and with its leading lineups on Tuesday, with ''Who's the Boss?,'' and Wednesday, with ''Dynasty.''

Bob Igiel, senior vice president of the NW Ayer ad agency, said ABC's progress and CBS' continued strength on Friday, with ''Dallas,'' and Sunday, with ''60 Minutes'' and ''Murder, She Wrote,'' will cause problems for NBC next season.

''The toughest thing to do is get to be No. 1,'' Igiel said. ''The next toughest thing is to stay there.''