There was a time, not so very long ago, when Matthew McConaughey was on the verge of becoming a punch line, if not a cautionary tale, an erstwhile new-thing-on-the-block who squandered early hype and promise on naked escapades involving bongo drums and ill-advised romantic comedies. The actor who turned heads in a scene-stealing cameo in “Dazed and Confused” then succumbed to pathologically publicity-savvy packaging in his “serious” screen debut in “A Time to Kill” had somehow wound up making “Ghosts of Girlfriends Past.”

A couple of years ago, though, McConaughey regained his footing, returning to the very instincts — part old-soul, part gonzo — that got him to the big show in the first place. With films like “The Lincoln Lawyer” (see it if you haven’t), “Bernie,” “Killer Joe,” “Magic Mike,” “The Paperboy” and this year’s sublime coming-of-age dramaMud,” McConaughey claimed his rightful place in America’s dark heart, a snaky, sinewy shape-shifter whose anti-heroics, even at their sleaziest, possessed an almost pastoral purity and innocence.

McConaughey has doubled down on the persona in “Dallas Buyers Club,” an alternately wrenching and exuberant fact-based drama for which he famously shed nearly 40 pounds to play an emaciated HIV patient. As Texas electrician Ron Woodroof, McConaughey delivers the performance of his career, characterized not just by an astonishing physical transformation but by a wellspring of deep compassion and fearlessness. Together with co-star Jared Leto — whose facial and corporeal transformation is every bit as startling — McConaughey personifies the kind of blazing, all-in commitment that defines screen acting at its simplest and its best.

From its very first scene, “Dallas Buyers Club” announces what kind of tough, even tawdry world it intends to inhabit: At a rodeo where cowboys are hurled into the ground like yard darts, Woodroof embarks on a wild, panting assignation of his own in the form of a furtive sexual encounter with two women in a stall just outside the ring. The year is 1985, and the gaunt, stringy Woodroof is leading the life of a large-livin’ good old boy whose drinking, gambling and hard partying eventually catch up with him in the form of a flu he can’t shake.

Except it isn’t flu, and the scene in which Woodroof learns from physician Eve Saks (Jennifer Garner) that he has contracted the AIDS virus is just the first of several in which McConaughey exhibits uncanny powers of expression, spontaneity, control and restraint. “Dallas Buyers Club” is nominally about Woodroof’s simultaneous efforts to overcome social stigma and buck the medical establishment and bring non-FDA approved treatments to desperate patients. But really the movie is about choices, in this case a protagonist’s unspoken evolution from homophobia to a begrudging, vaguely haunted humanism; an actor’s decision not to compulsively seek the audience’s love and approval; and a filmmaker’s decision to keep what might have become a saccharine parable of uplift on a harder, riskier edge.

Director Jean-Marc Vallée keeps “Dallas Buyers Club” real by rejecting high gloss in favor of a more spare, stripped-down visual style; reportedly he used only natural light to film, which keeps the often seedy subculture that Woodroof inhabits from becoming too cozy. But if that world — of trailer-park orgies and cheap motels, drug addicts and hookers — isn’t all sweetness and light, it isn’t devoid of heart. The soft, vulnerable soul of “Dallas Buyers Club” is a transsexual named Rayon (Leto), a misfit and fellow AIDS patient whom Woodroof initially spurns but who eventually becomes his business partner.

As a rousing, reality-inspired tale of someone sticking it to The Man, as well as a sober social history and sentimental chronicle of unlikely friendship and love, “Dallas Buyers Club” could have gone wrong in myriad ways, most of them having to do either with overkill or pompous self-seriousness. But Vallée, working with a lean, lively script by Craig Borten and Melisa Wallack, neatly avoids excess, letting Woodroof’s terrific yarn stand on its own and getting out of the way of his extraordinary actors, who channel the story without condescension or manipulative cheats. McConaughey and Leto may have the showiest roles, but Garner deserves equal praise for her sensitive, straightforward performance.

“Dallas Buyers Club” never allows viewers to forget that it’s taking place within an epidemic of staggeringly tragic proportions. But neither does it allow that grievous context to negate the energy and sheer entertainment value of Woodroof’s gutsy journey across the high wire between certain death, survival and redemption. Thanks to a wily coyote of a protagonist — and the actor who has made such characters such gratifying cinematic figures of late — “Dallas Buyers Club” turns the facts of a life into deeply grounded emotional truth. McConaughey hasn’t just become the devil we know. He’s become the one we love.

★ ★ ★ ★

R. At area theaters. Contains pervasive profanity, some strong sexual content, nudity and drug use. 117 minutes.