Viewers will be shocked at Matthew McConaughey’s emaciated appearance but—given the string of extraordinary performances he’s given since “The Lincoln Lawyer”—not the quality of his acting in “Dallas Buyers Club.”

McConaughey lost forty pounds to play Ron Woodroof, a Dallas electrician working the rodeo circuit who’s diagnosed as HIV-positive during the AIDS epidemic of the 1980s. A volatile, randy, hard-drinking fellow often in trouble with the law, he’s also instinctively homophobic (a trait which, if the recollections of those who knew him are accurate, the script exaggerates for dramatic effect), and insists that the doctors who give him the news after he’s brought in following a work-related accident must be wrong. But when he finds himself as shunned by his former friends as gay sufferers are by society at large, his attitudes gradually change.

That dramatic arc, however, is spurred by his immediate incentive to procure whatever drugs might be available, even on a trial basis, to treat the infection. Unable to get into the group testing AZT under the guidance of the very pair of physicians who diagnosed him, Woodroof bribes an orderly to steal the medicine for him, and when that avenue is closed drives to Mexico, where expatriate American Dr. Vass (Griffin Dunne) tells him that AZT is toxic and provides him with alternatives—vitamins and supplements as well as meds as yet unapproved by the FDA.

That sets off dollars signs in Woodroof’s head, and soon he’s smuggling the items into Texas as a commodity much in demand in the gay community, eventually going worldwide to secure the meds he wants. But rather than trying to sell them outright, he follows a clever distribution scheme. He sells memberships in a club, one of the perks of which is a monthly supply ostensibly for free—and he enlists to serve as a star salesman among his potential customers Rayon (Jared Leto), a drug-addict transsexual who was part of the AZT test group.

From this point “Dallas Buyers Club” turns into a David-and-Goliath story, with Woodroof facing off against FDA officials, who use every legal avenue at their disposal to shut his business down while continuing to promote the promise of AZT, despite dangerous side-effects of the drug. The implication, of course, is that the agency’s actions were incited by pressure—and perhaps financial incentives—from the pharmaceutical companies that could profit enormously from sales of their product. As the conflict escalates, Eve Sacks (pretty Jennifer Garner), one of the two doctors involved in the trials, gradually emerges as Ron’s principled, rebellious ally, while the other, Dr. Sevard (Denis O’Hare), aligns himself with the establishment and the myopia it represents. And, of course sparks fly between Ron and Eve, though for obvious reasons their relationship must remain platonic. Ultimately litigation will be required.

To a great extent the film, written by Craig Borten and Melissa Wallack and ably directed by Jean-Marc Vallee, follows conventions familiar from previous pictures. Woodroof’s transformation from hostile bigot to understanding, sympathetic brother to the gay community stretches back to Jonathan Demme’s twenty-year old “Philadelphia,” in which the lawyer played by Denzel Washington followed much the same emotional trajectory. More generally, the tactic of using an outsider to a mistreated community to make a story more accessible to viewers who might well be outsiders to it themselves, rather than just telling the story from within, is an old one that was repeatedly employed, for instance, in films about the civil rights struggle. (This would be a very different tale if Rayon were its central character, instead of a fictionalized catalyst to Woodroof’s transformation.) And, of course, the little-guy-against-the-system aspect of the narrative is an age-old device—one need only think of “Erin Brockovich,” for example.

Yet “Dallas Buyers Club” works, mostly because of McConaughey’s electrifying performance, which makes Woodroof the sort of high-octane rogue it’s impossible to dislike. And his triumph is closely matched by Leto’s, an inspired piece of work that even puts across a clumsy scene in which Rayon visits his estranged father in hopes of getting money to keep the club afloat. Together the two also manage to pull off the predictable scene in which Woodroof uses physical force to compel a bigoted friend (Kevin Rankin) to treat Rayon courteously rather than spit out insults at him.

Otherwise the cast aren’t terribly well used, with Garner stuck in a stock part and even Steve Zahn able to do little with the role of a Dallas cop who’s sympathetic to the trouble-making Woodroof. But Dunne underplays nicely as Dr. Vass, who’s essentially the instigator of it all. The mid-eighties milieu is reasonably well caught, and the general grubbiness of Woodroof’s world is certainly captured by production designer John Paino, art director Javiera Varas, set decorator Robert Covelman and costume designers Kurt and Bart, with similarly gritty cinematography by Yves Belanger. But it has to be noted that the picture wasn’t shot in Dallas, and the locations aren’t really a convincing simulacrum of the city, looking more like Louisiana (not surprising, since that’s where it was filmed).

“Dallas Buyers Club” can be criticized for shoehorning its story into a familiar framework to make it more comfortable for mainstream audiences. But the astonishing turns by McConaughey and Leto nonetheless give it a powerful charge.