WHAT IS MOST AMAZING about "Carandiru," Hector Babenco's brilliant, fact-based drama about events leading up to a notorious 1992 massacre in a Sao Paolo prison, is how a film so claustrophobic manages to feel, in the end, so expansive.

Rivaling "Das Boot" in its ability to convey the cramped, stifling feel of its setting -- a squalid penitentiary originally built to house 4,000 inmates, but holding 7,500 at the time of the film's action -- the narrative (co-written by director Babenco with Fernando Bonassi and Victor Navas) is structured as a series of flashbacks, so that it takes frequent excursions outside the walls of the giant jail, known as Carandiru after the subway station it abuts. Those interludes of breathing room, however, are only part of what gives this film its universal scope. Ultimately, it is "Carandiru's" ability to humanize its central characters -- to make you care about the murderers, thieves, junkies and whores who are Carandiru's citizens, and its doomed heroes -- that gives the movie its wrenching, tragic power.

Based on a memoir by Drauzio Varella, who worked as a physician in the prison's infirmary for many years, "Carandiru" begins on one of the man's first days on the job. As the doctor (Luiz Carlos Vasconcelos) tours the facility with the warden (Antonio Grassi), he comes upon a charged, potentially violent confrontation between two inmates. How that confrontation, and the revelation that a knife has been stolen from the facility's kitchen, is finally settled -- by the intervention of a sort of prison "fixer" known as Ebony (Ivan de Almeida), who uses the threat of arbitrary killings to flush out the thief -- provides clear, if shocking, evidence of just how this social microcosm functions . . . that is, as a mirror of the larger culture.

Sure, Carandiru is a kind of hell, but it is a hell with rules.

Those rules, for the most part, keep things running smoothly. Sex is rampant and accepted as a fact of life. Drugs and other contraband flow into the prison in a seemingly uninterrupted river. Debts are paid, one way or another. If not, killing the debtor is always an option, as long as the killing has been given the seal of approval by Ebony and other members of what appears to be a kind of city council made up of high-status inmates.

All this gets revealed through the eyes of the good doctor, who befriends his patients and clinic volunteers, listening to their alternately comic and harrowing tales of life on the inside and outside. Over the film's nearly 21/2 hours, we meet such people as the transvestite Lady Di (Rodrigo Santoro) and her sweet beau, Too Bad (Gero Camilo), who are "married" in a tender yet raucous jailhouse ceremony; the tattooed Dagger (Milhem Cortaz), who only knows how to kill, and is haunted, literally, by ghosts; and Highness (Ailton Graca), who juggles two wives during conjugal visits.

It's a proverbial rogue's gallery, and Babenco draws us deeper and deeper inside the portraits, until we're comfortably ensconced in their heads, and may even start to see ourselves, or our loved ones, in their eyes. When "Carandiru's" climactic violence erupts into a rolling boil -- precipitated by a trivial argument that leads to an all-out revolt, quashed by police with riot gear and automatic weapons -- it happens so suddenly that you might not even notice that Babenco has been slowly turning up the heat since the first frame.

During a recent screening, the audience sat in stunned silence, barely breathing, during the film's final 15 minutes or so. That's not just a tribute to the shocking brutality of its imagery, but to our real sympathy for its victims.

Babenco gets a lot of mileage out of Christlike compositions, pinning a bullet-riddled inmate against a wall of metal bars as if on a crucifix. His real triumph, though, isn't in making us aware that "Carandiru's" prisoners were martyrs, but that they were human beings.

CARANDIRU (R, 145 minutes) -- Contains violent carnage, streams of obscenity, partial nudity, and strong sexual and drug content. In Portuguese with subtitles. At Landmark's E Street Cinema.

"Carandiru," a drama about the 1992 massacre at a Brazilian prison of the same name, features Rodrigo Santoro, left, as the transvestite inmate Lady Di and Gero Camilo as Too Bad.