John Schwartz / New York Times News Service

Luciano Vincenzoni, an urbane Italian screenwriter who worked with Billy Wilder, Dino De Laurentiis and other giants of film but to his dismay was best known for writing two spaghetti westerns starring a young Clint Eastwood, died Sunday in Rome. He was 87.

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

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 De Laurentiis, the producer, released in the United States in 1962.

But to the general public 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 Sir 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 Leone’s film “A Fistful of Dollars,” which gave viewers a morally murky landscape and a taciturn “Man With No Name” character played by 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 Vincenzoni “had been in love with America” and that he had lived on and off in the United States for 20 years.

Vincenzoni wrote the screenplay with Leone for the follow-up, “For a Few Dollars More,” imbuing it with humor and irony that the first film lacked. Eastwood even smiled.Vincenzoni was also a canny businessman. In his book “Sergio Leone: Something to Do With Death,” Frayling relates an encounter between 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, 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.”

One U.S. executive asked what it would cost to make, and Vincenzoni responded, “1 million dollars.”

“He told me, ‘It’s a deal,’” Vincenzoni recalled.

“The Good, the Bad and the Ugly,” which starred 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. Between the vision of Leone, the acting of Eastwood, the music of Ennio Morricone and the writing of Vincenzoni, 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; “Orca” (1977); “Raw Deal,” with Arnold Schwarzenegger (1986); and “Malena” (2000), for which he wrote the original story.