NEW YORK (AP) _ Television's favorite fictional families - the Huxtables on ''The Cosby Show'' and the Keatons on ''Family Ties'' - helped NBC supplant CBS, the leader the past six seasons, as the nation's No. 1 network, season-ending figures from the A.C. Nielsen Co. confirmed Tuesday.

It was NBC's first outright triumph in three decades of Nielsen tallies. NBC tied CBS in prime-time ratings in 1969-70 and 1970-71 and ABC finished first three times in the late 1970s, but the rest belonged to CBS.

For the 30-week season that ended Sunday, NBC's back-to-back Thursday comedies finished one-two, replacing the soapy ''Dynasty'' and ''Dallas'' as television's most-watched series. The last time two comedies headed the ratings was 1978-79 with ''Laverne & Shirley'' and ''Three's Company.''

The rest of the 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?''

NBC finished the regular 1985-86 season with a 17.5 rating, an increase of 8 percent over last season's 16.2 mark. CBS fell from 16.9 to 16.7. ABC slipped from a 15.4 to 14.9. NBC also led in every age-group demographic, except adults over 55, which CBS still dominated.

At a New York press conference, David Poltrack, CBS' vice president for research, held high a plastic cup of coffee and toasted NBC. ''It was quite an extraordinary accomplishment,'' he said, noting NBC's gain of 1.3 ratings points over the previous season.

''I've been waiting 6 1/2 years for this,'' Brandon Tartikoff, president of NBC Entertainment, said during a satellite hook-up with television writers. Tartikoff's programs were third-rated for the first four seasons of his regime. NBC remains the only network without a weekly prime-time news magazine, and Tartikoff had once said that winning without one would necessitate an asterisk in the same way that Roger Maris' 61 home runs appear in baseball's record book. ''I'll take it with the asterisk,'' Tartikoff said Tuesday. ''It's fine. Today's a good day.''

There were no major signs of celebrating at NBC, perhaps because the network's triumph has been all-but official for weeks. NBC held a dinner in Burbank, Calif., Monday night for 500 employees. New York staffers will attend a luncheon May 2. NBC did order hundreds of purple rugby-style shirts with the logo: ''1985-86: That Championship Season.''

Because of NBC's increase in audience, network TV stemmed its ratings decline for the first time since 1976-77. Network viewing, which attracted a 48.5 rating last season, increased 1 percent to 49.1. This means the networks delivered, on average, 1 million more homes.

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

Only two seasons ago, no sitcom cracked the Top 10, prompting some industry analysts to suggest that 30-minute comedies could go the way of two extinct genres, the western and variety show. But comedy's premature obituaries were written B.C. - Before Cosby.

This season, there were five comedies in the Top 10 and 11 in the Top 20. Comedies averaged a 17.6 rating to last season's 15.4. Action-adventure series dropped from 15.9 to 14.7. Every prime-time serial dropped off in the ratings, but, because there were fewer failed new soaps this season than last, the form experienced an overall ratings gain from 19.5 to 19.7.

''The Cosby Show,'' which led in every age group except adults over 50, averaged a 33.7 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.''

NBC developed more new hits than CBS, which didn't have a single new success this season. NBC's comedy-anchored Thursday and Saturday lineups were its winning nights. But the network also made gains by not finishing third on any night. ''NBC has good balance,'' Poltrack said.

NBC also led in made-for-TV movies with 11 of the Top 20. CBS had nine and ABC, which used to dominate with its Sunday movies, had none. ABC did have the No. 1 miniseries, ''North and South.''

The top-rated TV movies were NBC's ''Return to Mayberry'' and ''Perry Mason Returns.''

''They got the No. 1 and No. 2 movies with our past hit shows,'' Poltrack said. ''Obviously, nostalgia is in.''