At first glance it hardly seems likely that “The School of Rock” would have much to offer to anybody whose age exceeded single digits. After all, this is a movie about an obsessive rock guitarist named Dewey Finn, who, after being dumped by his mediocre band, pretends to be a substitute fourth-grade teacher in a posh elementary school to make ends meet and trains his students, a staid bunch from even staider homes, to become rockers with the intention of entering them in the local “Battle of the Bands.” You might well start grinding your teeth in anticipation of what sort of cutesy, stomach-turning pablum will emerge from such a scenario.

But you’d be dead wrong. “School of Rock” turns out to be one of the happiest surprises of the fall season–a full-throated, energetic comedy that happens to have parts for plenty of kids but is in no way a typical kids’ movie. Smart yet also slightly demented, it’s a picture that children may well enjoy, but teens, twentysomethings, baby boomers and grandparents should find it a hoot, too. It’s that endangered species–a movie that’s really for everybody.

The improbable success of the picture has three main causes. One is Mike White, a clever, edgy writer (“Chuck and Buck,” “The Good Girl”) who was able even to put a new spin on a teen comedy with “Orange County.” Another is Richard Linklater, who brings his hip, loose, decidedly unsentimental style to bear on the material and keeps the picture from sliding into anything like mawkishness. Finally–and most important of all–there’s Jack Black, who seizes on a role perfectly in synch with his own persona and turns it into star-making turn of volcanic proportions. Black has always had a special connection with rock–that’s one reason why his performance as a manic record-store clerk in “High Fidelity” seemed so perfect, and his Tenacious D work has made him an MTV favorite. Here he uses that knack–and his amazing energy–to take hold of the camera and never let go. Black works so hard virtually every second in “School of Rock” that you might worry that any second he’ll keel over from cardiac arrest; but the effort pays off in a portrait of an obsessive rock fanatic so complete, and within the parameters of comic exaggeration so credible, that it’s unlikely it could ever be bettered.

And Black does this against a canny supporting cast–Joan Cusack as the school principal, screenwriter White as the nebbishy roommate whose identity Finn assumes to take the teaching gig–as well as a passel of urchins personable enough to steal scenes in handfuls from most adults. Linklater doesn’t allow the kids to become precious or sickeningly sweet under any circumstances, but Black plays against them so exuberantly that it’s like they were doing a sequence of duets, trios and quartets. It all clicks because, in effect, Black seems like a big kid himself. His interaction with the children is reminiscent of the way some guests meshed perfectly with the Jim Henson characters on the old “Muppet Show.” Most didn’t; they looked out of place beside the bags of fur and were at once upstaged by them. The same thing happens with plenty of able actors when they share a scene with kids. But not Black; he fits right in, and the result is a joy.

Inevitably “School of Rock” takes some sentimental turns toward the close, as Dewey’s imposture is revealed and his plan to win the Battle of the Bands with his kids is endangered. But even here the picture makes its way past the pitfalls with considerable dexterity. And the lack of glitz–the semi-gritty, independent look Linklater cultivates and his crew delivers–keeps things from becoming too slick, too. Needless to say, the all-important music score has been artfully chosen, too.

It’s hard to say how broad Jack Black’s comic gifts run; maybe he’ll never get a role so perfect for him again. All the more reason to appreciate the level of enthusiasm with which he fills it here. He puts “School of Rock” immediately near the top of the cinematic charts.