The “Uncut Gems” creators, Josh and Benny Safdie, are known for their merciless filmmaking style, made up of seedy underworlds and populated with first-time actors cast off the street. Howard Ratner is a composite character, partly based on the directors’ father, but reimagined with the same first name as his boss at a diamond business on West 47th Street. The Safdie brothers’ own childhood was worlds away from Sandler’s Jewish “Leave It to Beaver.” Josh describes his father, a Sephardic Jewish emigrant from France, as a “squeezed bohemian” with better intentions than decision-making skills. Often, his parenting style led the brothers into the kinds of situations that make great artists rather than well-adjusted children. In one minor infraction, in 1993, he gave them “They’re All Gonna Laugh at You!” — Sandler’s first comedy album and a masterwork in the genre of art that’s not exactly meant for kids but that is also perfectly attuned to their worldview. One sketch, titled “The Longest Pee,” is a Foley-arts extravaganza over two minutes long devoted to the sound of a urine stream hitting water. In another, “Toll Booth Willie,” Sandler plays an affable Mass Pike worker who, for reasons that go totally unexplained, is gratuitously insulted by every single motorist passing through Worcester. Benny and Josh, then 7 and 9, would listen to the album for hours at a time, splitting a pair of headphones between them.

“They’re movies on CD,” Josh says.

“They’re not just comedy records,” Benny says. “They’re worlds.”

When the brothers set out to make “Uncut Gems,” an arduous process that spanned about a decade, they knew from the start they needed Sandler to play Ratner. The character was a bad decision maker — a protagonist so rash he fell short of antihero — but he wasn’t meant to be an unsympathetic guy. “We wanted you to root for him to win,” Benny says. “Sandler, we knew, could bring that out of him.” Sandler has an almost singular finesse for making audiences love insufferable guys. (The Safdies were never quite sure that they would get him. At various points in preproduction, Sacha Baron Cohen and Jonah Hill were attached.)

Sandler isn’t easily persuaded to step out of his own well-controlled domain. More than just creative control, Happy Madison permits Sandler a calm, suburban life, even as one of the world’s most famous people. Movies shoot in summer, so he can bring his kids to set. During the year, the workday is arranged to allow him to drop them off at school and pick them up. For most parents, this is a fantasy arrangement, and Sandler knows it is something worth defending. Entering another filmmaker’s world upends the whole structure for months at a time and often entails taking huge creative risks alongside new and unfamiliar people. When the brothers finally got Sandler in a room, they quickly discovered that working together would involve arriving at a version of Ratner that Sandler would feel that he could play. “He’s a family man,” Benny says. “He would say things like, ‘Yeah, that’s going to be very hard for me to do.’ ”

The Safdies, who admit they “don’t have the greatest imagination,” write scripts through a kind of pseudojournalism, studying the textures of real life and reproducing them over and over until a fictional version comes naturally. Once the basic profile of Ratner was formed, they sent Sandler to the diamond district, where he spent several weeks absorbing microgestures — how a jeweler handles a phone, the particular way his voice might shift as he moves out of casual conversation into sales mode.

From there, the Safdies constructed microcosms in which Sandler could practice these skills. In one instance, they sneaked into a Barneys dressing room and staged an improvisational shopping scene with Ratner and his mistress, played by the fashion-designer-turned-actress Julia Fox. In another, they invited an odd mix of people — including a real-life jeweler who showed up with Liam Payne of One Direction — to a karaoke bar where Sandler, as Ratner, delivered a cocksure rendition of “Break On Through (to the Other Side).” “Adam, I think, was smart and brave to trust them in the way he did,” the producer Scott Rudin says. “He quickly realized that his innate caution was not going to be helpful to him in this movie, and whatever anxiety he felt about playing this guy, he managed himself out of. That takes an enormous amount of self-knowledge.”

When I asked Sandler to talk about this work, he expressed a kind of sheepish frustration that he wasn’t more articulate about his process. The costume — the false teeth, the diamond earrings, the cheesy transition lenses — was a big part of it, he said, because it allowed him to step into Ratner’s persona and forget about what his own family might think. “There was something about that outfit that made me feel a little more confident as a guy, a little more cocky and in control,” he told me. “I miss being that guy. I remember when we wrapped, and I was done with the leather jacket and the pinkie ring, I was like, ‘Oh, I’ll never have a reason to wear that again.’ ”

Critics tend to think of Sandler’s so-called serious acting as an anomaly within his comedy career, but inside his “Uncut Gems” performance, you’ll find all the parts of Billy Madison intact. His voice remains stilted. Beneath that stupid, pleading smile strains the tripwire of anger ready to explode. Sandler projects deranged optimism, pushing his luck with such a desperate lack of shame that Ratner feels both real and dislocated — as absurd as any Sandler character, but now with all the randomness grounded in the peculiar Jewish world of the diamond district. Sandler plays Ratner at a breakneck pace, entombing himself in a dungeon of his own bad decisions. It is — and I mean this as the highest compliment — the kind of performance that makes you want to pick your skin. When I asked if he was looking forward to the premiere, Sandler told me he was mainly worried about what his mother would think. Already, he’d spoiled the ending for her in hopes of softening the most brutal scene.