The actor is astonishing in the Safdies' rambunctious heist thriller, which takes place in a single frantic New York night.

In the opening minutes of Josh and Benny Safdie’s “Good Time,” Robert Pattinson bursts into the room and it’s clear he’s trying something different. With his black hair tousled above an angry stare and a silvery earring peering out from one side, he’s a scruffy, irrepressible ball of fury, eager to fix a problem and on the verge of making it worse. He’s abrasive, clumsy and a little bit fearsome. In other words: He’s in a Safdie brothers movie.

Anyone familiar with the sibling directors from their dreary NYC junkie drama “Heaven Knows What” or gritty urban comedy “Daddy Longlegs” knows how the brothers have assembled a universe of grimy characters enmeshed in bizarre, dangerous circumstances that can seem at once naturalistic and surreal. With “Good Time,” they transform that focus into a Kafkaesque heist movie, populated by maniacal characters careening through Queens on a doom-laden quest over the course of a single tumultuous night. It’s a wild, twisty maze of misbegotten plans by desperate people, and exists within the confines of their aggressive desire to get the job done.

This time, Pattinson provides the propulsive energy that makes the whole apparatus churn. Pushing beyond the muted roles for which he’s best known, the actor transforms into a vain, reckless character driven against impossible odds. The whole movie zips forward at an unnerving speed, and Pattinson’s tasked with making much of it believable — but he’s complemented by a co-star tackling a risky part: As two-bit bank robber Connie Niklas, Pattinson first appears opposite Benny Safdie, who plays Connie’s mentally disabled brother Nick.

Any suggestion of a reductive or insensitive performance on the actor-director’s part is quickly assuaged by Safdie’s quiet, measured turn; his distant eyes stuck in a frozen gaze, Benny’s Nick is a sad, gullible figure, but not a cartoonish simpleton. When Niklas bursts into a mental hospital to shelter his brother from a psychiatrist’s prying questions, Nick listens to his brother as they head for the exit and embrace. The jarring scene is filled with equal measures of chaos and affection. Again: It’s a Safdie brothers movie.

Connie’s a domineering figure intent on supporting his brother on his own terms, and when the pair rob a bank while wearing hoodies and rubber masks, at first it seems as though he’s slick enough to have concocted the perfect scheme. Minutes later, however, the situation takes a dour turn, as Sean Price Williams’ jittery cinematography chases the brothers through a hectic pursuit with the NYPD closing in.

Up to point, “Good Time” suggests “Of Mice and Men” by way of “Dog Day Afternoon,” but that’s only the prologue to the loopy subterranean odyssey around the corner. The rambunctious plot doesn’t stop twisting, veering from misanthropy to slow-burn suspense and eventually absurdist comedy, as if following the uneven contours of its troubled characters’ minds. Pattinson, his stern expression belying Connie’s mounting anxiety about his brother’s fate, channels the hopeless determination that keeps him going.

And he needs the extra push. Over the course of the night, Nick is detained by authorities and enmeshed in brutal late-night prison showdowns, while Connie bounces around town in search of help like Gary Cooper in “High Noon” with the velocity turned up to 11. At first, Connie seeks $10,000 for his brother’s parole, going so far as to trick an older squeeze into giving it to him; when that plot hits a wall, and Nick winds up hospitalized, Connie shifts gears to attempt an old-fashioned prison break.

Needless to say, that doesn’t go as planned, either. The ensuing misadventure finds Pattinson on the lam, hiding out in multiple households, joining forces with unlikely criminals, chasing buried treasure, and stealing a Sprite bottle of acid. The Safdies enhance the sheer lunacy of the plot with the unnerving tension of Connie’s messy journey around town, while the throbbing score by Daniel Lopatin (“The Bling Ring”) ensures the breathless pace never slows down.

That’s because Nick can’t afford to let that happen, and yet nothing he does is exactly right. After pulling off a daring rescue, he’s faced with a brutal punchline that throws him into far worse circumstances, and the rage in Pattinson’s eyes capture genuine emotion even as his situation strains credibility. It’s hard to believe that any of this will end well for him, but never less than thrilling to see him try to defeat the odds.

Pattinson’s dynamic performance is aided by the thuggish extremes of a hilarious drug-dealing Queens bro played by Buddy Duress who winds up in Connie’s car during the second act, exhibiting a goofier, self-absorbed opposite to the fragile heroin addict he played in “Heaven Knows What.” While Pattinson enters new territory, Durress is the movie’s real discovery — a hapless figure of despair who’s funny despite himself. For reasons too outrageous and strange to spoil here, the pair eventually join forces in a last-ditch attempt to score some dough and fix their problems.

The night takes on a phantasmagoric dimension when Connie arrives at a theme park after hours, but even this zany development contains an undertone of dread that lies at the root of the Safdies’ work, which has never been more exciting to watch than within the confines of this vibrant genre exercise.

“Good Time” ventures further and further into deranged circumstances with taut and ridiculous outcomes, in most cases leading to disorienting punchlines that speak to the underlying desire to make laughter catch in your throat.

After such powerful momentum, the brothers don’t quite stick the landing, but it’s a thrill to watch them try. More troubling is the way the only prominent female characters of the movie seem to inhabit shrill or clueless archetypes, as if the screenwriters (Josh Safdie and “Daddy Longlegs” star Ronnie Bronstein) decided they could only craft from the world of the movie from the narrow-minded perspective of its rash antihero. The Safdies may be working on a slightly bigger scale this time around, but the movie also shows the limitations of their range.

However, there’s simply no other modern American filmmaker capable of generating comedy and deep-seated suspense at the same time. “Good Time” combines anarchic sensibilities with an exacting style, its loopy plot starting in dark places and heads into willfully absurd directions before doubling back to a wakeup call. The essence of this unique directing duo’s appeal is they pin down what it feels like when crazy escapades die down and life gets real.

Grade: A-

“Good Time” premiered in Official Competition at the 2017 Cannes Film Festival. A24 will release it in August 2017.

Sign Up: Stay on top of the latest breaking film and TV news! Sign up for our Email Newsletters here.