Consider it one of the signal ironies of world cinema: The American director Martin Scorsese pines for three decades to make a great movie about urban gangs, and finally he gets a hundred million bucks from Miramax to turn his dream into reality.

And three years later, Miramax releases a great movie about urban gangs.

But that movie is not Scorsese's. It's not "Gangs of New York," it's the gangs of Rio. It's Fernando Meirelles' astonishment "City of God," about life and death -- well, mostly death -- in what used to be called slums. In short, it's a trip to Hell and back, and testimony for embittered cynics of all that a movie can be.

Do these pathologies sound familiar? Young men, no hope, too many guns, too much testosterone, crushing impoverishment, a macho mythology, a failed economy, municipal corruption everywhere, and rock music? Subtract the last, substitute knives for guns, and you could have any slum cesspool in the world over the last 4,000 years; restore the guns and the rock and you have . . . well, you pick 'em just about anywhere in the good old U.S. of A.; but you certainly have the City of God, the actual name of a huge housing project built in the '60s outside Rio that oozes pus and pestilence for the three generations that this movie tracks.

The movie is conceived as a kind of anecdotal history (it is derived from a huge novel by a survivor, an escapee from the place) of one of the world's previously impenetrable, blasphemed zones. It rolls across the decades, charting the rise and fall of petty empires, the brief supernova of gangster superstardom, the overturning of an older order by a yet meaner, more ruthless younger one; these events are lit up, here and there, by little spurts of recognizable behavior, even love.

It is a young man's movie: It adores action, swagger, local color, eccentricity, machismo, stupidity. Meirelles just can't stop telling stories, and he can't stop reveling in the goopy mud of bad behavior as it plays out in the swamp of heart and city. He's like a mad anthropologist who's found an undiscovered tribe in the mountains of New Guinea and can't leave it alone. You feel his love of his subject, of his own infernally gifted filmmaking, of the freedom he suddenly feels in features (he'd directed commercials in San Paolo); you feel the quickening of energy and endless possibility in him. So the result is a contradiction: a joyous film about murder.

"City of God" never gives itself over to pure nihilism. In fact, under the bravado, it's tragic, and that shell of ironic bravado keeps it watchable, though even that may be a close call for many genteel moviegoers: It's not for the weak of heart or stomach. Its evocations of casual, almost numbingly regular violence just go on and on and on. Plus, a chicken gets killed!

Our entree into the City of God is Rocket (Alexandre Rodrigues), who is too weak and smart to be a gangster (his brother's trade), yet too imaginative to be a fishmonger (his father's trade). Look into those big, sensitive eyes that drink in everything and you think: What can this poor kid become, except an artist? So a subplot follows Rocket's growth from one of those skinny wraiths on the dirt soccer field to ace photographer for the Rio de Janeiro Morning Bulletin-Bugle-Call, or whatever. It's funny, sweet (his continually frustrated sexual needs form a comic counterpoint) and ultimately not that interesting.

What is interesting is gangsters. The first law of gangster thermodynamics states that Gangsters Are Always Interesting, and the movie bears this out. These aren't gangsters like Scorsese's stovepipe-hat-wearing hooligans with their spiked curling clubs, and they're not Hollywood tommygunners named Scarface or Rico or Don Corleone. They're not a later generation's gangsta-rapsters with Berettas held sideways. No, they're, well, they're kids -- scruffy, dirty, scampering around on the dusty play-fields and squalid alleys, their body language expressing the weightlessness of their thin bones and scrawny chests, their clothes just any old rags, their feet bare or sporting flip-flops. You see them everywhere, but they don't carry guns everywhere. They carry guns only in the City of God.

Rocket's tale begins with his brother, who is a member of the Tender Trio, three strapping gunmen about 16, who tire of robbing propane trucks for pennies and decide to knock off a whorehouse at the urging of an even younger boy, known as Li'l Dice. Li'l Dice (Douglas Silva) is the real McCoy. Under his T-shirt and his china-thin chest beats the heart of the stone killer and the cool calculation of the big-timer. In the Bronx he'd become Lepke Buchalter or Lucky Luciano.

Li'l Dice's demonism will cast its violent shadow across the City of God for three decades, but who's to guess such a thing when they see the kid standing lookout for what appears to be a quick heist of a love motel? What the Tender Trio doesn't know is that after the guys have left with their $78.42 score, Li'l Dice follows them through the rooms, tidying up with a .32 revolver. He kills everybody, laughing at the pleasure it gives him.

From this single crime, Meirelles traces ripples; the three nominal thieves find their ultimately tragic (or, in one case, salvational) destinies; their exploits inspire another generation and Li'l Dice grows to stunted manhood, calling himself now Li'l Ze (Leandro Firmino De Hora Phellipe, in the film's most stunning performance). Ambitious and hardened by the harshness of his life and the harshness of his DNA, he returns to the slum and takes over, by an expedient so simple and so ruthless, no one had thought of it before.

Distilled to narrative essence, the movie might be considered an account of Li'l Ze's reign and the forces it unleashes, as new champions (notably Knockout Ned, played by Seu Jorge) rise against him, pushing him to yet higher reaches of barbarity. The chosen weapon here is the pistol, but this isn't gunfighting after the Hollywood style. It's more like touch football with guns: scampering, running, shooting quickly, racing away. When shot, the wounded or killed simply collapse as if their joints have melted. They cry or whimper, or they lie like broken dolls, barefoot in the mud. The many gunfights are different but the same -- they have an improvised quality to them, and they're raw and unpolished. Meirelles hasn't amplified or replaced the sound of gunshots with the thunder booms of the Hollywood product, so even the gunfire seems real, if you've ever heard it: thin, echoey, far off, more like distant hammer blows than detonations.

But the director pays as much attention to psychology as to gunfights. That's why Li'l Ze is such a monster: Unattractive and unsure of himself around women, he's got fiery resentment blazing for anyone luckier with them -- that is, fiery resentment against everyone. Thus the flimsiness of the offenses that set him off is truly terrifying; when he's turned down by a girl for a dance, he tracks down and humiliates her boyfriend, little realizing that in doing so, he is filling Knockout Ned with endless fury that will fuel gang violence for years.

What is astonishing about the film, beyond its pure movie fluency, is the presence of the young actors. These are not professionals. Rather, Mierelles found them on the streets, and gradually inculcated them to film culture through a series of workshops. Perhaps in no other way could he have captured the exuberance, the unself-consciousness, the pure naturalism that he does. Whatever, the movie feels like no other I've ever seen.

If one of the moral responsibilities of the movies is to put you in places where you'd never go and live lives you'd never live, then "City of God" is great moviemaking. This one admits no other moral responsibilities. It merely gazes pitilessly at the real, and maybe that reality is too hard to take. It offers scant optimism to policymakers of any stripe. It advises liberals that social programs are pointless when applied to the violent vitality of the streets, and it advises conservatives that stern bromides about responsibility are as ineffective against the will to violence as a fistful of feathers. It says man is dark and doomed and stupid. But it also says he's alive and kicking and magnificent.

City of God (133 minutes, at area theaters) is rated R for extreme violence.

Hard-nosed kids from the streets of Hell populate Fernando Meirelles' stunning film.Shoot with camera or gun? Alexandre Rodrigues' Rocket focuses on the future.