Ever since The Believer, I’ve believed in Ryan Gosling as a candidate for the next iconic male actor in American movies. Physically, he’s an odd-looking guy. He has a long, thin face with none of the square-jawed blankness of Josh Hartnett or the fey charm of Orlando Bloom or the dopey je ne sais quoi of Tobey Maguire or Jake Gyllenhaal. Instead, Gosling simply has his own confident energy on camera and he’s rarely mawkish or facile. I don’t know if he’s a particularly intelligent person, but as an actor he projects the same restlessness, the same impatience with mediocrity and sentimentality that characterizes the best work of Brando and Nicholson.

Although Gosling’s turn as a Jew-turned-white supremacist in The Believer was a tour de force, he has yet to find a definitive part, his own Stanley Kowalski or his own Randle Patrick McMurphy. His most popular film is probably his most atypical, that of the young lover in the Nicholas Sparks weepie The Notebook. He was fantastic as the seductive rich boy in Murder by Numbers, but that mediocre picture otherwise was most memorable for being the occasion for an off-screen affair between Gosling and co-star Sandra Bullock, 16 years his senior.

While it’s unlikely that Gosling’s role as Dan Dunne, the troubled junior high school teacher at the center of Half Nelson, will be a career-defining part, it’s a riveting performance all the same. In lesser hands, this character of a hip white teacher in a school that is almost entirely black could be excruciatingly phony, but Gosling’s charm is effortless. His Dunne is no ordinary history teacher who coaches the girls’ basketball team after school. Instead, he ignores the mandated lesson plans and riffs to his students about dialectical materialism and the real history of power relations in America. He’s the kind of radical teacher in the inner city that earnest lefties from the 1960s imagined they wanted to be. But this heroic pedagogue also has a little after-school problem: He’s a crackhead.

Dunne, we learn, is a failing writer who has also bungled a recent relationship. After a clumsy encounter with his ex-girlfriend, who seeks him out after a basketball game, he decides to slip into the girls’ locker room for a session with the pipe. One of his players, Drey (Shareeka Epps, an old soul in her early adolescence) discovers him there and responds with remarkable compassion, giving him water and remaining with him until he’s well enough to drive her home. The two now share a secret and develop an awkward relationship that is something less than a friendship by most standards, but for these two troubled urban loners, it becomes a lifeline of intimacy. Drey, we learn, lives with her overworked mother and has a brother doing juvenile detention for drug running. Although she’s a bright girl, she’s unsupervised and vulnerable to the blandishments of the neighborhood dealer (Anthony Mackie, in a fine turn), who wants her to perform the same duties that got her brother sent up.

Epps’ performance as Drey is a marvel in understatement–she says little, preferring to suck on a lollipop and watch what’s going on. Her reticence dissipates, however, when she spends time with Dunne. “Why do you have so many books about black people?” she inquires suddenly while perusing his book collection, which is heavy on Eldridge Cleaver, Malcolm X, Che Guevara and other fire-breathers.

Why, indeed, does Dunne have those books? We’re never given a complete life story by the writing/directing team of Ryan Fleck and Anna Boden, but it’s suggested that Dunne was born of once-idealistic parents who put aside their youthful illusions in favor of earning a solid living. Fleck and Boden’s script is simultaneously orthodox in its structure and bracingly didactic, as when they show, apropos of nothing in particular, clips of Mario Savio delivering an impassioned address in favor of free speech at Berkeley, or close-ups of Dunne’s students delivering their reports on such topics as gay politico Harvey Milk and the Attica prison uprising.

In this, their first feature film, Fleck and Boden have given us a film that dramatizes the vulnerable humans underneath the radical politics. Half Nelson is exceptionally well written and surprisingly funny, and it’s a marvelous opportunity for Gosling to demonstrate his ability to sink into a role and then come back to carry the film with his charisma.

Half Nelson opens Friday in select theaters.