Fred Astaire, 88, one of the great dancers of this century and an artist who transported generations of moviegoers into special realms of grace and elegance, died of pneumonia yesterday at Century City Hospital in Los Angeles.

In a cinematic career that spanned almost a half-century, Astaire starred in 40 films and his name became a synonym for high style. He also was greatly admired as a singer and an actor.

Ballet choreographer George Balanchine called him "the greatest dancer in the world . . . the most innovative, the most elegant dancer of our times. You see a little bit of Astaire in everybody's dancing -- a pause here, a move there. It was all Astaire's originally."

President Reagan, in a White House statement, said Astaire was "in every sense of the word a 'superstar' . . . . He was the ultimate dancer . . . the absolute master of his terpsichorean muse . . . . "

With his white tie and tails, top hat and a cane that he used as a swagger stick, Astaire made his film reputation during the Depression years of the 1930s, when the good life that his dancing seemed to suggest stood in stark contrast to the drabness and drudgery of everyday existence for most Americans.

He danced down staircases, he danced on balconies and rooftops, he danced in the living room and he danced in ballrooms and in the garden. In one picture, "Holiday Inn" (1942), he danced to exploding firecrackers, and in another, "Royal Wedding" (1951), on the walls and on the ceiling.

In 1933, he was cast with Ginger Rogers in "Flying Down to Rio," and together they danced a South American number, "The Carioca," that electrified audiences. They became a team and, in time, a legend. They appeared in only nine other films together, eight in the 1930s, and one, "The Barkeleys of Broadway," in 1949. With the exception of Rogers, Astaire had no other leading cinematic partners more than twice, and in the public mind he was always identified with Rogers.

"He was the best partner anyone could ever have," Rogers said yesterday from her home in Shady Grove, Ore.

Slim and urbane, Astaire had a way of making his intricate dance routines look effortless. In fact, they were the result of hard work and conditioning. "Just practice, sweat, rehearsal and worry," Astaire said. He was a perfectionist who prided himself in never repeating a number in any of his films.

His style on the screen was pleasing and light, and he almost always seemed to feel good about himself and enjoy what he was doing. This made his audience enjoy it, too.

Hollywood's initial scouting report on him was, "Can't sing . . . can't act . . . can dance a little." His voice was thin and reedy, but his presence on the screen more than compensated for that. Songwriter Irving Berlin once observed, "I'd rather have Fred Astaire sing my songs than anyone else."

Among the more memorable of Astaire's movie songs were, "Night and Day," "They Can't Take That Away From Me," "One For My Baby," "Puttin' on the Ritz," "A Fine Romance" and "A Foggy Day."

He embodied the fantasies of his movie fans when he twirled Rogers in her feathery evening gown to the music of "Cheek to Cheek" in the movie "Top Hat" (1935); when he won the dance contest with her in "Follow the Fleet"; when they danced on roller skates in "Shall We Dance" (1937); when he danced with three silhouettes of himself in "Swing Time" (1936), and when he danced in slow motion against a chorus line in normal motion in "Easter Parade" (1948).

He revolutionized filming techniques for the motion picture musical comedy. Before Astaire, dancers were generally photographed in sections, with the camera focusing on parts of their bodies rather than the whole. But Astaire insisted that the camera get all of his 5-foot-9-inch frame to illustrate the smoothness of his movement.

In reality, he was not like his cinematic image at all. "I must admit that I don't like top hats, white ties and tails," he said in his autobiography, "Steps in Time." "I am always arriving at dinner parties not wearing a dinner jacket when I should, or vice versa . . . . The carefree, the best dressed, the debonaire Fred Astaire. What a myth!"

Although sometimes mistaken for an Englishman, Astaire was born Frederick Austerlitz in Omaha, the son of a beer salesman. He began dancing lessons when he was 5 with his older sister Adele, and they soon became well known performing in local church halls.

A few years later their mother took them to New York to enroll them in a bigger dance school. Later they toured in vaudeville acts, and in 1916 they were offered a job in the Broadway musical "Over the Top."

During the 1920s, the Astaires became topflight stars in musical comedy, both in the United States and in Europe. In 1931, however, Adele Astaire left the stage to marry Lord Charles Cavendish, the son of the Duke of Devonshire.

This forced Astaire to find a new dancing partner, and after eight months on the New York stage, he went west to Hollywood to try the motion picture industry.

Paramount studios dismissed him and Goldwyn signed him but then released him after he had appeared in a bit part in a Joan Crawford movie. Not until RKO cast him with the wisecracking, blond Ginger Rogers in "Flying Down to Rio" did it appear that he had a career in films. Their subsequent hits included "The Gay Divorcee" (1934), "Roberta" (1935), "Carefree" (1938) and "The Story of Vernon and Irene Castle" (1939).

After Rogers, Astaire danced with such partners as Rita Hayworth, Eleanor Powell, Judy Garland, Jane Powell, Cyd Charisse, Leslie Caron and Audrey Hepburn. His other films included "You Were Never Lovelier" (1942), "Blue Skies" (1946), "Three Little Words" (1950), "Band Wagon" (1953), "Daddy Long Legs" (1955), "Funny Face" (1956) and "Silk Stockings" (1957).

He played his first straight dramatic role in 1959 in "On the Beach," a film about nuclear holocaust, in which he played a cynical atomic scientist. A year earlier he had made his television debut with a special called "An Evening with Fred Astaire," which got the highest television rating of any program up to that time, and which also won a record nine Emmy Awards. Later he did two other television specials.

Astaire retired from dancing after "Finian's Rainbow" (1969), saying that "dancing is an athletic career, and I don't want to do it all my life any more than Willie Mays wants to spend the rest of his life chasing fly balls. At my age I don't want to disappoint anyone, including myself."

He continued to appear in dramatic roles. A notable part was that of an ex-con man in the 1975 disaster epic, "Towering Inferno," for which he won an Academy Award nomination as best supporting actor.

He later costarred with Robert Wagner as a dapper crook in the television series "It Takes a Thief," and appeared at the age of 81 in the television space opera, "Battleship Galactica."

In 1948, Astaire received a special Academy Award for his "unique artistry and contributions to the techniques of musical pictures."

Astaire was an enthusiastic horseman and an owner and breeder of thoroughbreds.

His first wife, the former Phyllis Potter Baker, died of cancer in 1954 after 21 years of marriage. They had two children, Fred Jr. and Ava.

In 1980 he married 35-year-old Robyn Smith, a former jockey, who survives him.