Frank Pierson, who received an Academy Award nomination for his first screenplay, the western lampoon “Cat Ballou,” another Oscar nod for his script of the chain-gang drama “Cool Hand Luke” and then won the Oscar for his bank heist story “Dog Day Afternoon,” died July 22 at a hospital in Los Angeles. He was 87.

The death was confirmed by his manager, Susan Landau. No cause of death was disclosed.

Mr. Pierson, whose mother was an author and screenwriter, graduated from Harvard University and became a correspondent for Time and Life magazines before entering show business as a network television writer in the late 1950s.

In a career spanning five decades, he co-wrote the screenplay to the Scott Turow legal mystery “Presumed Innocent” (1990) and directed and co-wrote the Barbra Streisand-Kris Kristofferson rock-music remake of “A Star Is Born” (1976). As a consulting producer, he helped shape the story lines of recent series including AMC’s “Mad Men” and CBS’s “The Good Wife.” He was president of the Academy of Motion Picture Arts and Sciences from 2001 to 2005 and of the Writers Guild of America, West.

Mr. Pierson’s maiden screenplay — based on a Roy Chanslor novel — was “Cat Ballou” (1965). It starred Lee Marvin in Oscar-winning dual roles: a ruthless killer and a broken-down gunslinger who helps a schoolmarm (Jane Fonda). The movie also featured Nat King Cole and Stubby Kaye as the makeshift Greek chorus.

Frank Pierson, seen here in 2003, received Oscar nods for his screenplays for “Cat Ballou” and “Cool Hand Luke” and won for “Dog Day Afternoon.” (Amy Sancetta/AP)

“I think I was the 11th writer on the project, but they had all been trying to do it as a serious story,” Mr. Pierson told the reference guide Contemporary Authors in 1986. “The last writer before me, Walter Newman — whose name also is on the screenplay — continued to try to write it as a serious picture.

“He got so fed up with it finally that he said to the producers, ‘You know, every time I write this damn thing, it comes out funny.’ Somebody had the common sense to say, ‘Well, why don’t you go on and try it as a comedy?’ ”

In 1967, Mr. Pierson worked with Donn Pearce to adapt Pearce’s novel “Cool Hand Luke” about a Southern chain-gang prisoner (Paul Newman) who refuses to buckle to authority. Mr. Pierson came up with the film’s most quoted line — “What we’ve got here is failure to communicate” — spoken to Luke by the brutal crew captain (Strother Martin).

Pearce, a former convict, said he “hated” the line, that it sounded too writerly for a chain-gang captain. The remark, he told the Palm Beach Post in 2007, “was snide and untrue and unrealistic.”

His was the minority opinion. Writing in the New York Times, film critic Bosley Crowther praised the “sharp script” with helping elevate “this brutal picture above the ruck of prison films and into the range of intelligent contemplation of the ironies of life.” In 2005, the American Film Institute ranked the “failure to communicate” line No. 11 among the top 100 movie quotes.

Mr. Pierson won an Oscar for his original screenplay of “Dog Day Afternoon” (1975), which was based on a bank robbery in Brooklyn. The film, directed by Sidney Lumet, starred Al Pacino as a would-be thief who tries to steal money for his lover’s sex-change operation and becomes caught in a hostage situation beyond his control.

Appearing last year at a film festival in San Francisco, Mr. Pierson credited Pacino with helping make the screenplay so effective.

“Al said, ‘Let me ask you a question: In your relationships that involved love and commitment . . . in your lifetime whenever you made a major decision whether to move in together . . . or get divorced or whatever . . . when all the decisions were made did any sex ever come into it?’ ”

Mr. Pierson agreed that it did not. Pacino then advised, “Take out all the kisses and the mentions of lovemaking. . . . Just write a story about two people who love each other and find a way to learn to live with one another.”

“It’s the greatest gift an actor has ever given me as a writer,” Mr. Pierson said.

Frank Romer Pierson was born May 12, 1925, in Chappaqua, N.Y. His mother, the former Louise Randall, was best known for her feisty memoir “Roughly Speaking,” which became a 1945 film starring Rosalind Russell.

After Army service in the Pacific during World War II, Mr. Pierson received a bachelor’s degree from Harvard in 1950. He spent the next eight years on the Time-Life staff, leaving to focus full time on scriptwriting for shows including the CBS western series “Have Gun — Will Travel.”

Mr. Pierson later directed such television programs as “Citizen Cohn” (1992), an HBO film starring James Woods as the anti-Communist lawyer and powerbroker Roy Cohn, who died of AIDS.

Mr. Pierson’s movie-writing credits included the thriller “The Anderson Tapes” (1971), starring Sean Connery, and the Vietnam War drama “In Country” (1989), featuring Bruce Willis.

His marriages to Polly Stokes and Dori Derfner ended in divorce. Survivors include his wife of 22 years, Helene Szamet; two children from his first marriage; and five grandchildren.

Mr. Pierson, who stood well over six feet tall, was known for public bluntness about the film community. In 1976, he wrote a notoriously acid account in New York magazine of working with Streisand and her then-boyfriend, producer Jon Peters, on “A Star Is Born,” which he condemned as a vanity project gone awry.

In a 2003 graduation speech at the University of Southern California’s film school, Mr. Pierson expressed dismay at Wall Street’s tendency to impose itself on the once-clubby film studios with an army of “demographers, pollsters and marketing experts” seeking risk-averse blockbusters that appeal to a teenage boy — “this pimply, oversexed slob with the attention span of a chicken.”

“Movies are more than a commodity,” he said. “Movies are to our civilization what dreams and ideals are to individual lives: They express the mystery and help define the nature of who we are and what we are becoming.”