Frank Pierson, the Oscar-winning writer of “Dog Day Afternoon,” former president of the Academy of Motion Pictures & Sciences and a consulting producer on “Mad Men” as recently as this past season, died Monday after a short illness in Los Angeles. He was 87.

Pierson’s electrifying script for Sidney Lumet’s “Dog Day Afternoon,” a classic film of the 1970s that captured the zeitgeist of the era, deservedly won an Oscar. He was thrice nominated for screenplay Oscars, having also picked up shared mentions for “Cat Ballou” and “Cool Hand Luke” — he was the creator of the famous line from the latter, “What we have here is failure to communicate.”

Pierson served two terms as president of the Writers Guild of America West from 1981-83 and from 1993-95 and remained active in guild affairs, including during the 2007-08 strike. He was AMPAS president from 2001-05.

In recent years he had been a consulting producer on “The Good Wife” and subsequently on “Mad Men” and penned an episode of the former in 2010 and of the latter in 2012. He had begun in television, serving as a writer, story editor and associate producer on “Have Gun — Will Travel” in the early 1960s.

After three seasons on “Mad Men,” he had been expected to return for the show’s sixth season.

“Mad Men” creator-exec producer Matthew Weiner praised Pierson as a sharp and insightful producer who was generous in sharing his life experience and encouraging to younger writers.

“He would share stories with you that were basically the jumping off points for entire episodes,” Weiner said.

Despite his long resume and advancing years, Pierson was determined to keep working, Weiner said. Pierson was impressed by “Mad Men” in its first season and reached out to Weiner for a job. When Weiner asked why he wanted to be in the daily grind, Pierson gave him an eloquent speech about the dangers of retirement — which wound up being delivered almost word for word by Robert Morse’s Bert Cooper character to John Slattery’s Roger Sterling in the “Mad Men” season-three finale.

Pierson was also a director of feature films including the 1976 remake of “A Star Is Born” and “King of the Gypsies.” He picked up Emmy nominations for directing prestige pictures for television “Citizen Cohn,” starring James Woods; “Conspiracy,” starring Kenneth Branagh; and “Soldier’s Girl.” Other telepics he directed included “Neon Ceiling”; “Lakota Woman: Siege at Wounded Knee”; “Truman,” starring Gary Sinise; and “Dirty Pictures.”

Pierson’s first featuring scripting credit was on 1965 Western comedy “Cat Ballou,” starring Lee Marvin and Jane Fonda. Pierson and Walter Newman adapted Roy Chanslor’s novel. He scripted prison movie classic “Cool Hand Luke” with Donn Pearce based on Pearce’s novel. Other feature writing credits include Lumet’s “The Anderson Tapes,” starring Sean Connery; Norman Jewison’s “In Country,” starring Bruce Willis; and the adaptation, with director Alan J. Pakula, of Scott Turow’s novel “Presumed Innocent,” starring Harrison Ford.

Frank Romer Pierson was born in Chappaqua, N.Y. His writer mother penned an autobiography, “Roughly Speaking,” that was turned into a 1945 Warner Bros. film of the same name starring Rosalind Russell and Jack Carson as Frank’s parents. Frank Pierson served in the. Army in the Pacific during WWII and graduated from Harvard in 1946 with a degree in cultural anthropology.

He was a correspondent for Time and Life magazines, serving in their Beverly Hills bureau. “Then one day,” he later told Denis Faye for the WGA West, “I realized I was writing long reports to dispatches to Time and Life and big patches of my prose were going straight into the magazines but under somebody else’s name, and I got so pissed about not being credited for the things I was doing, I thought I’d get into the movie business, where I’d get credit.”

Pierson first sold a script to “Alcoa-Goodyear Theater” before going to work at “Have Gun — Will Travel.”

The WGA showered Pierson with plaudits. He most recently shared the WGA Award for drama series for “Mad Men” in 2010. Earlier he drew a shared nod for “Cat Ballou,” a WGA kudo for “Dog Day Afternoon” and the Laurel Award for Screen Writing Achievement in 1992, and he was one of few people to win all three of the guild’s honorary nods: the Valentine Davies Award in 1991, the Edmund J. North Award in 1999 and the Morgan Cox Award in 2006.

He won DGA Awards for “Citizen Cohn,” “Truman” and “Conspiracy.”

Pierson won the Humanitas Prize’s Kieser Award in 2005.

In recent years he was also on the teaching staff of the Sundance Institute and was artistic director of the American Film Institute.

He had served as governor of the Academy’s writers branch for 17 years.

Writer-director Phil Alden Robinson, Academy governor for the writers branch, said in a statement: “Young rock ‘n’ rollers always look to the old bluesmen as models of how to keep their art strong and rebellious into older years. For screenwriters, Frank has been our old blues master for a long time. He’s always shown us — better than anyone else — how to do it with class, grace, humor, strength, brilliance, generosity, and a joyful tenacity.”

Pierson is survived by his wife Helene, his children Michael and Eve and five grandchildren.

A private funeral for the family will be held this week, and a public memorial will be planned in the near future.

Donations may be made to Stand Up 2 Cancer.