The show treats sex workers like any labor group. Illustration by Kristian Hammerstad

In a late episode of “The Deuce,” two young men, blissful, curl up after sex. One lover praises the other for his brand-new fame—strangers drove miles to see him. “That’s worth celebrating, baby,” he says. His partner scoffs: “Like it’s normal to watch people fucking on film.” The other man gazes up, as if spotting a new constellation, and says, softly, “Maybe it is.”

It’s one of many intimate exchanges in “The Deuce,” a sweet rarity for HBO: a drama full of hardcore sex and violence, but one with an elastic generosity, a willingness to see even the ugliest phenomena through curious eyes. For two decades, sex has been the network’s killer app—it’s what made HBO, doubly, “adult entertainment.” If you watched “The Sopranos,” you got a V.I.P. seat at the Bada Bing; past midnight, there were egghead-voyeur documentaries like “Hookers at the Point.” Later, HBO perfected the model, with a set of date-night blockbusters, particularly “Game of Thrones” and “Westworld,” along with the rotten coke-and-punk fantasia of “Vinyl” (a misfire that played like a seventies wing of “Westworld”). An HBO drama about Times Square in 1971 could easily have been more of the cynical same—just another girlie magazine tucked inside a dissertation about man’s inhumanity to man.

Instead, David Simon and his frequent collaborator, the novelist George Pelecanos, together with writers such as Megan Abbott, have made a show that is quietly transformative: a portrait of the sex trade at the moment when, as James Wolcott put it, in “Lucking Out,” his memoir of the period, “porn swamp-gassed into an atmospheric condition.” The first season patiently traces the industry’s emergence, as under-the-counter reels became peep shows, then velvet-rope premières. In many ways, “The Deuce” is a classic David Simon urban joint: it treats sex workers as emblematic of any alienated workforce. (Management and labor, pimps and girls from Minnesota: same diff.) But it’s also a clear-eyed portrait of a lost universe of Manhattan decadence, neither sentimental and glamorizing nor disapproving and didactic. It’s a show about a grimy, brutal world, but one that treats desire itself as something profound and complex, not just a slick widget for the male consumer.

The key is the characters. The star of “The Deuce” is, superficially, James Franco, who plays twin brothers: Vincent, a decent, hardworking bartender who becomes a reluctant player in the “pussy trade,” and Frankie, an irresistible bad boy. Franco is solid; the camerawork is clever. But, for all the actor’s mustache-wrangling panache, these roles can seem contrived, like two modes of playing “Grand Theft Brothel.” Luckily, Vincent is more host than hero, introducing a vast ensemble. There are five pimps and more than a dozen street prostitutes, from Thunder Thighs to Lori, a canny newcomer from the Midwest. There are cops, mobsters, a female reporter from the Amsterdam News, and a college girl turned barmaid. The streets themselves are lovingly re-created, right down to the World Trade Center, then under construction, and the marquees, which alternate between “Thar She Blows” and Bertolucci’s “The Conformist.” Early episodes emphasize grotty details, like the rats in a stag-film theatre, but Times Square is also a small town: when Frankie passes a hooker on her knees in a phone booth, he calls out, “Hey, Ronnie.”

The show is especially audacious in its exploration of the bond between pimps and whores—an intimacy that other characters find baffling. The pimps, who are black, with the exception of one goofball hippie, consider themselves bully philosophers, and brag about plucking “product,” of every race, from the Port Authority bus station. But, though they may be management, they’re in the trade, too; their game is to use sex itself to render the girls desperate, glued to their abusive bosses by more than mere fear—a racialized hypermasculinity that proves fragile once Mob-run brothels move in. Some of the liveliest scenes take place in a beat-up diner, where everyone gathers at the crack of dawn, to eat eggs and gossip, a grimly companionable demimonde that resembles an office cafeteria.

Maggie Gyllenhaal is spectacular as Candy, an iconoclastic glamour-puss who works without a pimp and who glimpses, earlier than anyone, the potential of porn. (The character is, in part, based on the feminist-porn entrepreneur Candida Royalle.) Emily Meade and Jamie Neumann are perfect as two spokes in a painful love triangle. But the stealth standout is Dominique Fishback, as Darlene, a short, smiley, brown-skinned country girl, who is introduced as a naïf, a soft touch who tears up at old movies. Over eight episodes, Fishback turns this heart-of-gold stereotype into something original, with a spiky blend of weariness and savvy that’s more than mere victimhood. Even at the bottom of the ladder, there’s someone below you.

The porn scene doesn’t fully emerge until a few episodes in, in the aftermath of obscenity challenges in court. Along the way, we get eccentric details, like the fact that, as a legal work-around, early porn was performed without film in the camera—just pervs paying to watch a fake shoot, complete with a “director.” There’s a let’s-put-on-a-show slapstick wildness to the nascent industry, down to the cold potato soup shot out of a baster. “There’s been a change in the law about community standards,” one porn producer explains. “Apparently, New York has none.”

Still, the misogyny is never underplayed. As Wolcott (not exactly the world’s greatest women’s libber) put it, “The contempt for women that often wore a sneer in porn films on its liver lips was an everyday dragon-snort in Times Square.” The satirical Web site the Reductress neatly nailed the earnest contradictions of modern feminism on this theme, in a post titled “Why I Feel So Passionately That Sex Work and Porn Is Problematic but Empowering but Good for Them but Bad for Them.”

“The Deuce” is certainly a feminist series—and half its directors are female—but its smartest move is to resist turning sex into a thesis, exploiting the contradictions instead. Often, this means visually scrambling cable clichés, starting with a rape role-play in the première that spills into genuine violence. In the aftermath, Darlene, dabbing her bruises, is nude, but she’s never the camera’s focus. Instead, our gaze keeps settling, with nosy clarity, on her bald trick’s big-bellied torso, his matted back hair, his exposed crotch, forcing us to consider that body—both pathetic and intimidating—not hers.

There’s warmth, too, particularly through Gyllenhaal’s mournful, electric presence, her fame itself upending the hierarchies of cable, which typically dictates that extras bare it all while the stars cover up. With the polarities reversed, and the biggest celebrity somehow exposed and not objectified, I found myself craving a sex scene between the one non-sex-worker African-American couple on the show: in this context, such a sequence became elevating, not debasing, a sign that the characters were taken seriously enough to see their private world.

I’ve read a few reviews that insist that no one could get turned on by “The Deuce,” a judgment framed as praise. That strikes me as unlikely—and, also, beside the point. There are sad scenes here of transactional rutting; there are also loving ones, and plenty that walk a line, like one in which an abusive pimp gives his girl a screaming orgasm. But the show’s gift is that it doesn’t imagine that liberation and a trap are so easily distinguished, in bed or out of it, a truth that resonates long past 1971.

In one beautifully edited sequence, Lori watches herself having sex. The first shot is from inside a peep-show machine: we are the camera, gazing into her eyes, rapt and aroused. The second is from behind, so we see her as the male customers do: a small brunette in a fleece-trimmed jacket, ignoring them to look at herself. But the show doesn’t view her response as any kind of joke. It understands that, when the world aims at erasing you, it’s a thrill to be made visible, by whatever means necessary. ♦

An earlier version of this piece misidentified Frankie, one of the identical twin characters played by James Franco.