A film still from Studio 54 by Matt Tyrnauer (courtesy Sundance Institute)

In 1977, Studio 54 opened in New York’s red-light district, northwest of Times Square. The blinged-out club — located in a former opera house that cost at least $400,000 to renovate — brought the thriving gay underground dance scene out into the open. Embracing cultural diversity and celebrating personal freedom in a seedy corner of the city, it almost immediately became a coked-up celebrity gossip mill.

From its opening night to its downfall a mere 18 months later, Studio 54 was both a pure lovefest and a careerist cesspool, according to a gripping documentary that just premiered at Sundance. The club helped the likes of Andy Warhol, Bianca Jagger, Liz Taylor, Diana Ross, Grace Jones, Truman Capote, and Michael Jackson to burnish their reputations with stories fed directly to Page Six.

When Studio 54 crashed, it crashed hard. Agents from the Internal Revenue Service showed up one day, flashing a warrant and hauling away its business records. It turned out that co-founders Steve Rubell and Ian Schrager — friends from college who shared the outer-borough ambitions of Brooklyn strivers — had been skimming 80 percent of the take. They pleaded guilty and were sentenced to several years in federal prison on tax evasion charges.

Directed by Matt Tyrnauer, a Vanity Fair correspondent who previously directed a film on the Italian fashion designer Valentino, Studio 54 finds a compelling and sympathetic witness in co-founder Schrager, who later became a boutique hotelier. Schrager’s memories of his friendship with Rubell, and the lost community they nourished, lends the film unexpected heart. After all, this is the club that supposedly invented the velvet rope to turn away the unshaven masses and the nylon-wearing “bridge-and-tunnel” crowd.

Film poster for Studio 54 (courtesy A&E Indie Films)

Schrager offers a jarringly raw account of his role — the good, the bad, and the almost-tears of shame, not to mention the criminal liability — while speaking passionately about the values of mutual care that guided the club’s operation. Everyone was like family, he and many of his employees attest. Those who said otherwise were presumably left on the cutting-room floor.

The film also suggests that the operation may have had a familial connection to the mob, if only one generation removed: Schrager’s father was allegedly associated with the notorious Purple Gang. Uncannily, the McCarthyite mob attorney Roy Cohn (whom Donald Trump seems to idolize for his willingness to bully and tell brazen lies) appears throughout Studio 54, representing Schrager and Rubell in their tax evasion case.

At any rate, cultural winds shifted, reversing the club’s ill repute and creating new respect for the way that disco crashed together black, Latino, and gay subcultures. Soon the same roots would grow into the first hip hop recordings, while punk and heavy metal went in the opposite direction, denigrating disco for reasons that were often explicitly racist and homophobic. Many did not survive to tell their story. In the following decade, Rubell and half of the staff died of AIDS.

Tyrnauer artfully balances these subtleties, mining archival images from photographers like Bill Bernstein, Bill Cunningham, and Marcia Reznick, and weaving in recently discovered 16-mm film reels that were hidden away by a staff member. The footage bumps to the beat of a classic soundtrack that has also come back into vogue among DJ connoisseurs: “Soul Makossa” by Manu Dibango, “More More More” by Andrea True Connection, “Young Hearts Run Free” by Candi Staton, and “Don’t Leave Me This Way” performed by Thelma Houston.

Today, Schrager is a developer of multi-million-dollar real estate, known for high-priced hotels and condos designed by architects like Herzog & de Meuron and John Pawson, as well as artists like Julian Schnabel. He caters to the same desire for exclusivity that, depending on where you sat in the class and cultural divide, made Studio 54 both attractive and repugnant. In 2017, before leaving office, President Obama pardoned Schrager. As this film is perhaps too obligated to its subject to suggest, the jury is still out on the role he played in converting a free and bohemian city into a citadel of wealth.