John Huston, 81, who directed such enduring Hollywood classics as "The Maltese Falcon," "The Treasure of the Sierra Madre" and "The African Queen" while creating a personal legend that would have done credit to the rogues who often graced his films, died in his sleep yesterday at a house he was renting in Middletown, R.I.

The cause of death was not announced, but Huston had heart and lung ailments for years. He was hospitalized in Fall River, Mass., this month for treatment of pneumonia complicated by emphysema.

His longtime companion, Marcella Hernandez, was with him at the end.

Huston was one of the most honored figures in the film world, and he was the son and father of other honored figures. His father, the late Walter Huston, and his daughter, Anjelica Huston, won Academy Awards for roles they performed under his direction.

He was in Middletown for the filming of "Mr. North" in nearby Newport, R.I. It is is based on "Theophilus North," a story about man and manners by Thornton Wilder, and it is being directed by Huston's son, Danny. The elder Huston had hoped to play a leading role in it in addition to being executive producer, but failing health forced him to relinquish his part to Robert Mitchum.

The 40 films that Huston directed include some of the most notable movies ever made. And through his gifts as a screen writer and actor he had a hand in still other famous productions. For example, he wrote the script and received an Oscar nomination for "Sergeant York," for which Gary Cooper won an Oscar, and Huston gave a riveting performance as the corrupt old man in "Chinatown."

In addition to "The Maltese Falcon" (1941), "The Treasure of the Sierra Madre" (1948) and "The African Queen" (1951), in which Humphrey Bogart won an Academy Award, Huston's credits as a director include "The Asphalt Jungle" (1950), "Moulin Rouge" (1952), "Heaven Knows, Mr. Allison" (1957), "The Misfits" (1961), "The Man Who Would Be King" (1975) and "Prizzi's Honor" (1985), which brought him a renewed outpouring of critical acclaim in the twilight of his career. His last film, "The Dead," has yet to be released.

Huston won Academy Awards for writing and directing for "The Treasure of the Sierra Madre," the film in which Walter Huston won the Academy Award for best supporting actor for his portrayal of an aging and accommodating gold prospector. In 1985, John Huston's daughter Anjelica won an Oscar for best supporting actress for her role in "Prizzi's Honor," a satire on manners and morals in the mob.

In 1943, Huston, then an officer in the Army Signal Corps, made "Report From the Aleutians" and it won an Oscar for best documentary in its category. In 1956, he received the New York Film Critics award for best director for "Moby Dick." In 1983, he received the life achievement award of the American Film Institute.

He was nominated for Academy Awards for best director for "The Asphalt Jungle," "The African Queen" and "Moulin Rouge." As a screen writer, he received Oscar nominations for six films in addition to "Sergeant York": "Dr. Ehrlich's Magic Bullet," "The Maltese Falcon," "The Asphalt Jungle," "The African Queen," "Heaven Knows, Mr. Allison" and "The Man Who Would Be King," a wonderful adaptation of the Rudyard Kipling story starring Sean Connery and Michael Caine.

Although he cast himself in a number of bit parts, it was not until 1963 that Huston made his acting debut in a major role. He played a bishop in "The Cardinal," the Otto Preminger film, and he was nominated for an Oscar for best supporting actor. He directed himself as Noah in "The Bible" (1966), his most profitable film, and he played M, the head of the British Secret Service, in "Casino Royale," which he also directed. In addition to "Chinatown," he had important roles in "Battle for the Planet of the Apes," "Winter Kills" and "The Wind and the Lion." More recently, he has been familiar to millions for roles he played in television commercials.

Although many of his films are adventure stories in which the hero is tripped up by some flaw in his character -- in "The Man Who Would Be King," for example, Connery's avarice costs him his life -- Huston always claimed that there was no unifying theme to his work.

"Directing is simply an extension of the process of writing," he told an interviewer for Film Quarterly in 1965. "The most important element to me is always the idea that I'm trying to express. The audience should not be aware of what the camera is doing. They should be following the action and the road of the idea. I don't believe in overdressing anything. No extra words, no extra images, no extra music. But it seems to me that this is the universal principle of art."

In practice, he gave his actors minimal instructions. "He feels, for the kind of money we get paid, we ought to know how to do it ourselves," Michael Caine once said. When Katharine Hepburn had difficulty in "The African Queen" with her role as Rosie Sayer, the well-born missionary, Huston simply said: "Eleanor Roosevelt. Let her be your model." But he once twisted Lauren Bacall's arm to get her to produce just the right expression.

If he was sure-handed as a director, his personal life often seemed vivid, tumultuous and chaotic. Huston was a spendthrift who made and spent several fortunes. He was a gambler who loved to play the horses, a hard drinker, a brawler who got his nose broken in a fight with Errol Flynn, an honorary officer in the Mexican cavalry, and a master of foxhounds in Ireland. He was married five times, divorced four times and made a widower once. He survived numerous failed romances.

Despite failing health and the need to use supplementary oxygen, he never lost his zest for life.

"I don't like the part of being bound," he said in an interview. "But I've never discovered an answer to that question of what does freedom really consist. If you aren't fettered by one thing, you're fettered by another.

"I'm not hungry or thirsty. I'm not lovelorn. I'm just at the end of a piece of plastic tubing. And we're all hostages in one way or another."

John Marcellus Huston was born Aug. 5, 1906, in Nevada, Mo. He grew up in Texas and his first memories were of horseback riding. His parents separated when he was 6.

When he was 11, it was determined that he had an enlarged heart and nephritis. His mother took him to California because of its better climate. There it was discovered that most of his health problems were caused by a poor diet that had been prescribed by doctors in Texas.

He soon was restored to robust health, and he became a boxer in high school. In the 1920s, he went to New York. Through his father's connections he was cast in two plays. But there was no immediate follow-up. He spent the next 10 years in Los Angeles, Mexico, London and Paris, trying to make a living as a writer.

His career in films began in 1935 when he joined Warner Bros. as a scriptwriter. Early credits included "The Amazing Dr. Clitterhouse," "Juarez," "High Sierra" and "Sergeant York." His success won him a chance to direct and his first assignment was "The Maltese Falcon." This started his association with Humphrey Bogart, with whom he made six movies. Other stars in the film were Peter Lorre, Sydney Greenstreet and Mary Astor.

In 1947, Huston joined the Committee for the First Amendment, a group that protested the House Un-American Activities Committee's efforts to root out communists in the film industry.

Huston's wives were Dorothy Harvey, Lesley Black, Evelyn Keyes, Enrica Soma and Celeste Shane. He was divorced from all except Miss Soma, who died after a prolonged separation.

He had five children, Anjelica and Tony, whose mother was Miss Soma; Danny, whose mother was Zoe Sallis, and Allegra and Pablo, whom he adopted.