Surprisingly ignored by the Sundance jury (though ranked first in an Indiewire poll of journalists at the festival), the Brooklyn-set Half Nelson pays fond tribute to, even as it slyly subverts, the inspirational classroom fable. “We were always conscious of the Stand and Deliver/ Dangerous Minds scenario, and trying to avoid the clichés of that genre,” says director Ryan Fleck, who co-wrote the film with his partner, Anna Boden.

In essence, the movie stakes its bets on Ryan Gosling, who comes through with an astonishing performance, as a dedicated teacher attempting to inspire his inner-city eighth-graders with impassioned lectures on dialectics. His disastrous personal life starts to intrude on his job, though, when one of his students (Shareeka Epps) finds him strung out on crack in a toilet stall.

Fleck and Boden’s script undercuts its rigid schema with oddball wit and political smarts. The pair have some nonfiction experience, having directed last year’s Cuban hip-hop doc Young Rebels, and they fostered an air of low-key vérité on Half Nelson by encouraging the cast to improvise. Epps underplays her part beautifully, and Gosling, perhaps the most mentally agile of young American actors, is beyond credible—he’s practically heartbreaking.

Sardonic yet moving, Half Nelson deftly outlines the perils of youthful idealism without lapsing into knee-jerk cynicism. “We felt (Gosling’s) character was someone who grew up thinking it was important to impact the world in some way but didn’t really know where to start,” says Boden. The film splices in brief history lessons, delivered to camera by the students, ranging from Pinochet to Brown v. Board of Ed. “Even though it’s an intimate character study, I wanted to work in larger political themes,” says Fleck, who was born to radical parents on a commune in Berkeley and grew up in the Bay Area. “At least among people we know, politics is part of everyday conversation. It’s a reality a lot of movies don’t deal with.”