Thomas Meehan, a onetime magazine writer who became a three-time Tony winner on Broadway, writing the plot and dialogue for the blockbuster hit musicals Annie, The Producers and Hairspray, died Tuesday at his home in New York City. He was 88.

The cause was cancer, said his wife, Carolyn Meehan.

Meehan once aspired to be a serious novelist, but he turned toward journalism and humor because “whenever I wrote Faulkner-esque, it came out lousy-esque.”

He worked for a decade at the New Yorker, where he wrote one of the magazine’s classic humor pieces, “Yma Dream,” about an imaginary cocktail party for the Peruvian singer Yma Sumac. In a feat of dazzling wordplay, Meehan portrayed a beleaguered host opening his door to a series of guests, all with disyllabic first names, including Ava Gardner, Abba Eban, Ida Lupino, Ilya Ehrenburg and on and on: “The bell rings again, and I am pleased to find Oona O’Neill, Charlie Chaplin’s wife, at the door. She is alone. I bring her into the room. ‘Oona, Yma. Oona, Ava. Oona, Abba,’ I say.”

Finally, actress Uta Hagen joins the party, and the round-robin introductions become a blizzard of dadaist nonsense: “Uta, Yma; Uta, Ava; Uta, Oona; Uta, Ona; Uta, Ida; Uta, Ugo; Uta, Abba; Uta, Ilya; Uta, Ira; Uta, Aga; Uta, Eva.”

Director Martin Charnin asked Meehan to adapt Yma Dream for an Emmy Award-winning 1970 television special featuring actress Anne Bancroft. While working on the project, Meehan met Bancroft’s husband, writer-director Mel Brooks.

“All the major people in my life,” he later said, “and we met on the same day.”

Two years later, Charnin asked Meehan to help write a musical based on the comic strip Little Orphan Annie.

“I said it was a horrible idea,” Meehan told the Toronto Star in 2004. “Fortunately, I changed my mind.”

As a devotee of the novels of Charles Dickens, Meehan began to sense the dramatic possibilities in a story about Annie, a poor girl from an orphanage, the mogul Oliver “Daddy” Warbucks, and Annie’s dog, Sandy. With heart-tugging songs by Charles Strouse (and lyrics by Charnin), Annie opened on Broadway in 1977 and ran for six years.

Meehan won a Tony Award for best book for a musical. In Broadway parlance, the “book” is the plot development and spoken dialogue of a musical — “everything that isn’t sung,” as Meehan put it.

“A bad book can kill a musical,” he told the Los Angeles Times in 2004. “You have to tell a coherent, somewhat logical story, and you have to create characters who the audience cares about. If they don’t care about them, then they can sing all they want, but it won’t matter.”

After a few Broadway flops, Meehan joined forces with Brooks in 1983 to write the screenplay of To Be or Not to Be, a remake of a 1942 movie spoofing Nazi Germany. Four years later, they collaborated on Spaceballs, another Brooks vehicle that was a sendup of sci-fi films.

The pair later sought to remake Brooks’s 1967 film The Producers as a musical for the stage. The film ended with the two lead characters, scheming theatrical producer Max Bialystock and accountant Leo Bloom, in prison.

“The first thing I said to Mel was, ‘It can’t end like the movie with the two guys in jail,’ ” Meehan said in 2004. “ ‘If they want to be a success in Broadway, then they’ve got to make it by the end.’ ”

Meehan changed the beginning and ending, eliminated some characters and even added a few jokes not in the original. With Nathan Lane and Matthew Broderick in the starring roles, the revamped The Producers opened in 2001 to sold-out houses and rave reviews and ran for six years. Its 12 Tony Awards, including one for the book by Meehan and Brooks, are still the most in Broadway history.

The pair later worked together on a filmed version of The Producers, thus transforming a movie into a stage play and back into a movie.

Then in his 70s, Meehan was suddenly the hottest writer in musical theatre. In 2002, he had another Broadway hit, collaborating with Mark O’Donnell on Hairspray, a musical adaptation of a 1988 film by John Waters.

Loading... Loading... Loading... Loading... Loading... Loading...

The play, about a Baltimore teenager who becomes a celebrity on a TV dance show, won Meehan his third Tony and became an even bigger box-office hit than Annie and The Producers, running for 2,642 performances from 2002 to 2009.

Meehan’s later projects included Young Frankenstein with Brooks (2007), a 2010 stage adaptation of the Will Ferrell holiday film Elf and a 2014 musical version of the 1976 boxing movie Rocky, on which he sharing the writing credit with Sylvester Stallone.

“Underdogs getting what they want in the end,” Meehan said in 2004. “That’s what all my shows are about.”

Thomas Edward Meehan was born Aug. 14, 1929, in Ossining, N.Y. He was in his early teens when his father died; his mother was a nurse.

Meehan graduated in 1951 from Hamilton College in Clinton, N.Y., then served as an army intelligence officer for two years. After short-lived jobs in journalism, he joined the staff of the New Yorker in the mid-1950s and became a colleague of several of his literary idols, including S.J. Perelman and James Thurber.

In the mid-1960s, Meehan wrote for the U.S. version of That Was the Week That Was, an early forerunner of satirical TV programs about current events such as The Daily Show. He lived in France in the late 1960s while working on a novel that was never published.

His first marriage, to Karen Termohlen, ended in divorce. Survivors include his wife of 30 years, the former Carolyn Capstick of New York; two children from his first marriage; three stepchildren; a brother; and six grandchildren.

Meehan’s other theatrical projects included a musical version of I Remember Mama (1979), Bombay Dreams (2004), set in the world of Bollywood movies, a 2008 adaptation of the Waters film Cry-Baby and a 2012 musical about the comic actor and filmmaker Charlie Chaplin.

Meehan also collaborated with poet J.D. McClatchy and composer Lorin Maazel on the libretto for an opera treatment of George Orwell’s novel 1984, first performed in 2005 in London.

Shortly before his death, he completed a musical version of the 1941 Barbara Stanwyck film The Lady Eve.

“I think of my career, quote career, it’s just one thing after another,” Meehan told the New York Observer. “Just bumbling along like you don’t know what’s around the next turn, which is what I always wanted.”