The cause was cancer, said Federico Vincenzoni, a grandson.

Mr. Vincenzoni contributed to about 70 films, chiefly as a screenwriter or script doctor. His humorous touch could be found in films like "Seduced and Abandoned," which he made with Pietro Germi in 1964, and "The Best of Enemies," which Mr. De Laurentiis, the producer, released in the United States in 1962.

But to the general public Mr. Vincenzoni was most associated with "For a Few Dollars More" and "The Good, the Bad and the Ugly," two hugely successful Italian-made westerns directed by Sergio Leone that are now recognized as classics.

"I have written movies that won prizes at Cannes and Venice," he told Christopher Frayling, a cultural historian and Leone biographer. "These were screenplays for which we suffered on paper for months. Do you know how long it took me to write 'For a Few Dollars More'? Nine days."

The spaghetti western craze began with Mr. Leone's film "A Fistful of Dollars," which gave viewers a morally murky landscape and the taciturn Man With No Name played by Mr. Eastwood. Released in Italy in 1964 and in the United States in early 1967, the movie revitalized the western genre.

"He was more appreciated in the United States than in Italy," his grandson said, adding that Mr. Vincenzoni "had been in love with America" and that he had lived on and off in the United States for 20 years.

Mr. Vincenzoni co-wrote the screenplay with Mr. Leone for the follow-up, "For a Few Dollars More," imbuing it with humor and irony that the first film lacked. Mr. Eastwood even smiled.

Mr. Vincenzoni could be a canny businessman. In his book "Sergio Leone: Something to Do With Death," Mr. Frayling relates an encounter between Mr. Vincenzoni and Hollywood executives from United Artists who had come to Italy to see "For a Few Dollars More," which was breaking box office records. They not only bought the overseas rights but also wanted to know about the next film in the series.

With the "tacit agreement" of his Italian partners, Mr. Vincenzoni told the author, "I began to invent things," spinning out the idea for a movie on the fly, describing what would become "The Good, the Bad and the Ugly." (Mr. Vincenzoni, Leone and two other screenwriters are credited in the film.)

One American executive asked what it would cost to make, and Mr. Vincenzoni responded, "One million dollars."

"He told me, 'It's a deal,' " Mr. Vincenzoni recalled.

"The Good, the Bad and the Ugly," starring Mr. Eastwood, Lee Van Cleef and a magnificently bumbling Eli Wallach, reached the United States in late 1967.

The British film critic Raymond Durgnat called the trilogy "the code of the West as it might have been interpreted by Machiavelli."

The films, far from being cheap entertainment, "changed the way we look at the West," said Jeffrey Richardson, the curator for Western history, popular culture and firearms at the Autry National Center in Los Angeles. With the vision of Mr. Leone, the acting of Mr. Eastwood, the music of Ennio Morricone and the writing of Mr. Vincenzoni, Mr. Richardson said, "the package that these four contributors were able to put together radically transformed the genre" and in the 1960s "signified where America was at the time."

Some took a less exalted view. In The New York Times, the critic Renata Adler called the third film "The Burn, the Gouge and the Mangle," writing that it "must be the most expensive, pious and repellent movie in the history of its peculiar genre."

Luciano Vincenzoni was born in Treviso, Italy, on March 7, 1926. Besides his grandson, he is survived by a son, a daughter and two other grandchildren.

His first film, "They Stole a Tram," appeared in 1954. Other films, some decidedly lowbrow, included "Duck, You Sucker" (1971), also directed by Leone, and "Orca" (1977). He wrote or co-wrote the original story for two other films, "Raw Deal," with Arnold Schwarzenegger (1986), and "Malèna" (2000).

Mr. Vincenzoni seemed mystified that his more serious work, like "The Great War," would not seal his reputation, along with his friendship and collaboration with major figures like Mr. Wilder. He and Wilder worked together on the 1972 comedy "Avanti!" with Jack Lemmon and Juliet Mills.

"He never rated his work on Leone's westerns as highly as everyone else," Mr. Frayling said of Mr. Vincenzoni. Mr. Vincenzoni was able to take more pride in the westerns in his later years, though by then his relationship with Mr. Leone had soured over issues of money and credit. "He regretted not making his peace with Leone before he died," Mr. Frayling said.

"The last time I saw him, he actually cried," he said, adding that Mr. Vincenzoni had told him, "I just wish I had shaken Leone's hand before he died, because there was bad blood between us — we both behaved like idiots."

He concluded, "As the more cultured man, I should have known better."

Elisabetta Povoledo contributed reporting.