The cause was complications from the coronavirus, said press agent Matt Polk, adding that Mr. McNally had chronic inflammatory lung disease.

With his supple, approachable plays, Mr. McNally emerged as a pivotal American dramatist, particularly as art and politics collided during the AIDS crisis in the 1980s and 1990s.

AD

His body of work comprised dozens of plays, nearly a dozen musicals and several operas. His modes ranged from anxious farces and social critiques in the 1960s and 1970s, when the gay-bathhouse romp “The Ritz” (1975) was his biggest hit, to the warmhearted “Love! Valour! Compassion!” (1994), which illustrated the lives of eight gay men vacationing at a lake house. His “Corpus Christi,” which depicted a Jesus-like figure and his disciples as gay, ignited a firestorm in 1998.

AD

After decades of qualified successes and setbacks, Mr. McNally had a run of Tony triumphs in the 1990s that made him a commercial force. He won the award for best book of a musical with “Kiss of the Spider Woman” (1993) and “Ragtime” (1998), adapted respectively from novels by Manuel Puig and E.L. Doctorow. He won the Tony prize for best play with “Love! Valour! Compassion!” and “Master Class” (1995), a comic drama about the imperious opera star Maria Callas giving lessons on art and life.

Mr. McNally, who had surgeries for lung cancer, also received a lifetime achievement Tony in 2019, accepting the honor with breathing tubes strikingly visible over his tuxedo. “Not a moment too soon,” he joked.

AD

In a career spanning six decades, Mr. McNally became known for writing bespoke, bravura roles for big stage personalities. “I’ll write you a play,” he often promised scene-stealing actors he admired, among them Nathan Lane, Chita Rivera, Christine Baranski and James Coco.

AD

His sweeping output included the working-class romance “Frankie and Johnny in the Clair de Lune” (1987) and “The Full Monty” (2000), a crowd-pleasing musical (the score was by David Yazbek) based on the hit film about unemployed British steelworkers who become male strippers. Mr. McNally’s serio-comedy “A Perfect Ganesh” (1993), about two Connecticut matriarchs who travel to India to seek emotional and spiritual renewal, was a Pulitzer Prize finalist.

The work that dominated and defined his contribution to theater was the Tony-winning “Love! Valour! Compassion!”

AD

“Everyone talked about the full-frontal male nudity of that play,” said Raymond-Jean Frontain, author of “The Theater of Terrence McNally: Something About Grace” (2019). “But the final scene in which the men join hands and wade out into the lake and disappear at the back of the stage — they wade into the waters of the unknown, and they will escort each other to the other side, to whatever there is after death. That’s what you see in McNally play after McNally play: Grace is an entirely human phenomenon. You don’t need a transcendent entity to save individuals. We do it for each other.”

AD

Mr. McNally, who became one of the country’s most produced and honored playwrights, spent the first half of his life struggling with alcohol and with the fact that others, even some of his lovers, did not accept that he was open with his sexuality while they were not.

One of his early romantic partners, playwright Edward Albee, whose 1962 drama “Who’s Afraid of Virginia Woolf?” was heralded as a masterpiece, played down his sexuality to avoid being labeled a “gay” playwright.

AD

“I became invisible when press was around or at an opening night,” Mr. McNally later told the San Francisco Chronicle. “I knew it was wrong. It’s so much work to live that way.”

Mr. McNally found a durable voice midcareer with a string of widely produced comic dramas. Most prominent among them was “Frankie and Johnny in the Claire de Lune” — “the first play I wrote after I got sober,” he told the New York Times. The two-character study was staged on Broadway in 2002 with Edie Falco and Stanley Tucci and was revived in 2019 with Audra McDonald and Michael Shannon.

AD

Mr. McNally’s subject matter darkened as the AIDS crisis intensified. Watching closeted friends die alone in the early years of the AIDS epidemic, he once said, “made me more militant than ever about being out.”

AD

His mournful, accusatory drama “Andre’s Mother” (1988), about a woman who refuses to accept her dead son’s homosexuality, grew from its eight-minute original form to an hour-long 1990 American Playhouse film starring Richard Thomas. “Lips Together, Teeth Apart” (1991) examined two straight couples vacationing in a beach house bequeathed to one of the women after the death of a brother who had AIDS. The fretful foursome decline to use the pool.

“A comedy that hurts,” Times theater critic Frank Rich wrote of the off-Broadway production that starred Baranski, Lane, Swoosie Kurtz and Anthony Heald. “Because Mr. McNally can see right to the bottom of both his world and the people who inhabit it, most of his recent works . . . offer unsentimental hope about the possibilities for intimacy at a time when fear and death rule even beachfront land.”

AD

As his work increasingly became a cornerstone of New York theater and the nation’s regional circuit, Mr. McNally extended his reach further with his books for high-profile projects in the era of megamusicals.

AD

His first major musical credit came with the 1984 John Kander-Fred Ebb show “The Rink,” starring Rivera and Liza Minnelli as a battling mother and daughter. He was reunited with Kander, Ebb and Rivera for the dusky, glamorous epic “Kiss of the Spider Woman,” which opened on Broadway in 1993 and told the story of two Latin American political prisoners — one gay, one straight.

Moving into the operatic scale, Mr. McNally adapted “Ragtime” with lyricist Lynn Ahrens and composer Stephen Flaherty. Brian Stokes Mitchell co-starred with a young McDonald in a tale of archetypal American culture clashes.

AD

A lifelong opera fan, Mr. McNally wrote the libretto for “Dead Man Walking,” composer Jake Heggie’s opera about capital punishment that premiered in 2000, based on a book by the Catholic nun Helen Prejean.

AD

Love of grand performance drove much of Mr. McNally’s work, including the farces “It’s Only a Play,” about a dreadful opening night, and “The Lisbon Traviata,” about Callas buffs (played by Lane and Heald). Both shows enjoyed successful off-Broadway runs, in 1986 and 1989, respectfully. “Master Class” showcased Zoe Caldwell as Callas recalling personal sacrifices and artistic triumphs, and cowing the audience with bromides.

“You. Yes, you. . . . You don’t have a look. Get one. As quickly as possible,” Mr. McNally’s Callas commanded a hapless spectator each night, reliably bringing down the house. “It’s much easier than practicing your scales.”

AD

Mr. McNally’s hard-won momentum came to a halt at the end of 1998, with a painful fracas over “Corpus Christi,” titled for his Texas hometown.

AD

The Manhattan Theatre Club, which premiered most of his best-known work, canceled the production after receiving bomb threats but reinstated it under pressure from the artistic community. When it opened, the script was not well-received.

“The excitement stops right after the metal detectors,” began the Times review by critic Ben Brantley. “The play that brought an outraged chorus of protest even before it went into rehearsal is about as threatening, and stimulating, as a glass of chocolate milk.”

Mr. McNally, still licking his wounds over the controversy and the harsh response, told The Washington Post in 2002, “It’s saying gay men have as much right to participate and say ‘Christ is us’ as any other men.”

AD

Michael Terrence McNally was born in St. Petersburg, Fla., on Nov. 3, 1938, and grew up in Corpus Christi, the son of a beer distributor and a homemaker.

His parents, both native New Yorkers, whetted his appetite for show business by taking him on trips to see legendary Broadway productions: “Annie Get Your Gun” starring Ethel Merman and “The King and I” with Gertrude Lawrence.

In his youth, he became enraptured by Callas, whose voice he heard on the radio.

“I heard sympathetic vibrations. That’s the only way I can say it,” he told the Los Angeles Times. “That person is talking to me. That person has feelings I can get solace from. . . . Later, I learned about her tragic life, about the glamour, the gaining weight, the losing weight, the loss of her lover. But when I was 15 years old, I knew none of that. I only knew that it was something I liked.”

His upbringing was also fraught.

Mr. McNally said he was harassed and beaten because of his homosexuality and said his parents, while loving and encouraging of his theatrical yearnings, were also alcoholics. “There wasn’t a day when my parents weren’t drunk,” Mr. McNally said in “Every Act of Life,” a 2018 documentary about the playwright.

He received a bachelor’s degree in English in 1960 from Columbia University, where he wrote the annual Varsity Show and where he made a beeline for Broadway, lining up at midnight for tickets to the hit musical “My Fair Lady.”

“I spent my first night as a freshman sitting on the sidewalk in front of a darkened theater,” he later recalled. “If that didn’t make me some kind of an instant New Yorker, I don’t know what would.”

Mr. McNally endured lacerating reviews for his first original Broadway play, “And Things That Go Bump in the Night” (1965), a grim, high-strung satire of family dysfunction with a doomed gay man at the center. “There’s no place to go but up,” Mr. McNally often joked about that start.

Politics and sexuality marked Mr. McNally’s subsequent works from the 1960s, including the revolution-themed “¡Cuba Si!” and the swingers’ comedy “Noon,” about five people answering a personal ad. In 1969, he tooled “Next” for Coco; Elaine May directed the comedy about an overweight middle-aged man mistakenly drafted by the Army. “The Ritz” earned Rita Moreno a 1975 Tony for playing aspiring actress Googie Gomez, a role Mr. McNally wrote for her and that she reprised in the 1976 Richard Lester film.

Along with his successes, Mr. McNally was forced to confront his growing alcohol addiction. At a party in 1980 celebrating the 50th birthday of the composer and lyricist Stephen Sondheim, an intoxicated Mr. McNally spilled a drink on actress Lauren Bacall, who became irate.

Actress Angela Lansbury quietly confronted him about his drinking — an encounter that he said helped turn him around. (In 2007, he wrote the short-lived Broadway comedy “Deuce” for Lansbury and Marian Seldes as retirees recalling their long-ago tennis partnership.)

In 2000, Mr. McNally’s longtime partner, playwright and AIDS research activist Gary Bonasorte, died of AIDS-related lymphoma at 45. In 2010, Mr. McNally married lawyer and producer Tom Kirdahy. In addition to his husband, survivors include a brother.

Mr. McNally also had a three-year romantic relationship with “The Heidi Chronicles” playwright Wendy Wasserstein, ending in 1990. “I thought of myself as a person who gets in relationships with other men and suddenly I was in a significant relationship with a woman,” he told the Los Angeles Blade, a newspaper for the gay community. “It was just a surprise, and you know, life is filled with surprises.”

For all his influence on theater, stretching the form was not among Mr. McNally’s lasting contributions, although his note to performers about the “poetic realism” of “Frankie and Johnny” — “realer than real,” he insisted — captured his twin obsessions with human connection and the heightened power of the stage.

“I had a very strong desire to make myself heard,” he wrote in the 2015 collection “Selected Works: A Memoir in Plays.” “I would become a writer to accomplish this. If there were alternatives, they never occurred to me.”