Alberto Moravia, 82, whose books examining sex, alienation and the disintegration of middle-class values made him Italy's best known and most widely respected contemporary writer, died of a heart attack Sept. 26 at his home in Rome.

The author of more than 20 novels, Mr. Moravia won an international audience through translations and film versions of many of them, notably "Woman of Rome," starring Gina Lollobrigida as a Roman prostitute, and "Two Women" with Sophia Loren, who won an Academy Award for her portrayal of an Italian woman who is raped by Moroccan soldiers in World War II.

Mr. Moravia carved out a cultural and intellectual niche at the age of 21 with his first book, "The Time of Indifference," which told of the decline of middle-class values in the early days of Italian fascism. His most prolific period was the 1940s and 1950s. In addition to "Woman of Rome" and "Two Women," his novels of that time included "Disobedience," "Conjugal Love," "The Conformist," "Ghost at Noon" and "Empty Canvas."

When "Fancy Dress Party," a novel about an elaborately uniformed dictator, appeared in 1941, fascist authorities suppressed it on the ground that it was a satire of Benito Mussolini. In 1952, the Vatican placed all of Mr. Moravia's books on its Index of Forbidden Books on the ground that they were immoral. The index was discontinued after the Second Vatican Council in the early 1960s.

In 1970, Mr. Moravia shocked the literary world with a new novel, "The Two of Us," a dialogue between a sexually hyperactive screenwriter and his sexual organ. Some critics described it as the author's surrender to alienation.

In more recent years, Mr. Moravia wrote film reviews, travelogues and short stories. But in 1988, he published "The Journey to Rome," a best-selling novel about a boy in Rome and the familiar Moravian themes of alienation and sexual awakening. His last collection of stories, "The Friday Villa," appeared in August and has since sold about 50,000 copies. An autobiography is due to be published next month.

Italian President Francesco Cossiga, in a message of condolence, described Mr. Moravia as a "sharp but very sensitive narrator of 20th-century Italian society, its contradictions, bewilderments and anxious search for values."

Mr. Moravia, whose real name was Alberto Pincherle, was born in Rome on Nov. 28, 1907, the son of a well-to-do Jewish architect from Venice and an Austro-Hungarian countess.

He had a lonely childhood and spent most of it in a sanatorium after contracting tuberculosis. The disease and a later car accident left him with a pronounced limp. During World War II, he spent several months hiding among peasants because of his partially Jewish background.

Mr. Moravia once confessed he had found life boring from the time he was very young, but he defended himself against critics who said he endlessly repeated themes of apathy and indifference.

"Good writers are monotonous, like good composers. Their truth is self-repeating . . . . They keep trying to perfect their understanding of the one problem they were born to understand," he said in a 1988 interview.

In his seventies, he became active in politics and was elected in 1984 to the European Parliament with the backing of Italy's Communist Party.

In 1986, at the age of 78, he caused a stir by marrying Carmen Llera, a 32-year-old Spanish advertising executive, two months after the death of his first wife, Elsa Morante, a prominent novelist in her own right. They had been separated for 24 years and had no children.

In 1988, Mr. Moravia became the focus of unwelcome attention because of a widely reported love affair between his new wife and Lebanese Druze leader Walid Jumblatt. She was flying home from Morocco to attend the funeral.

Looking back on his life, Mr. Moravia described it recently as "a chaos in which the only continuous thread is literature."