The vignettes of torture that comprise most of “Saw,” an otherwise typical killer-thriller, are startlingly well-planned and executed. The violence of those scenes is so gory that it could only compare to “The Passion of the Christ.” The movie, at its best, is so beautifully sadistic that it seems to be the work of the exquisitely insane. (Who else could make mutilation interesting?) But at its worst, “Saw” falls victim to most of the flaws one would expect of the genre.

The film begins with one of the worst set-ups in cinematic history: Two men are chained to pipes in a dingy bathroom with a bleeding corpse. One is Adam (Leigh Whannell, the film’s screenwriter), a struggling photographer who lives vicariously through his subjects. The other is Dr. Lawrence Gordon (Cary Elwes, most memorable as Westley in “The Princess Bride”), a surgeon who is too busy to spend quality time with his crumbling family.

They soon realize that they each have a casette tape in their pocket and that the dead man lying in the middle of the room has a tape player (and a gun) in his hands. Through the cassettes, a man ominously named Jigsaw challenges Adam to stop being passive and change the course of his life. Dr. Gordon is told that he must kill Adam before 6 o’clock or his wife and daughter will be murdered.

Despite a terrible screenplay that is brought to life with acting that closely resembles bad high school drama, the film’s first half-hour is unimpressive but tolerable.

But what follows is, for the most part, a series of brilliant terror. Jigsaw sets up symbolically potent challenges for his victims, similar to those arranged by John Doe in David Fincher’s “Se7en” (an incomparably better film). Interestingly, the killer never actually murders anyone, apparently following the moral compass that guides him to choose victims who have somehow gone astray. As a result, he forces the film’s main characters to face ethical and psychological challenges. The gimmick is functionally effective, but not at all revelatory (see “Se7en” and lots of others).

The film is at least partially redeemed by the concepts of the torture vignettes, even if they’re not perfectly executed. When things seem to be unfolding in the expected progression of horror movies, “Saw” throws in thoughtful, almost intellectual twists. The intertwined fates of Adam, Dr. Gordon and the other characters — as well as the tactics to which they resort in order to survive — provide a riveting psychological study. And, even better, it is horrifying.`

The film culminates in a surprising, though questionable, twist. Above all, it is so startling that Jigsaw’s preachy villainy and the atrocious characterizations are practically forgotten. But the Dungeons and Dragons-like, Renaissance-fair cape Jigsaw wears remains unforgettable.

The exceptional horror of the film’s best vignettes are the reason to see “Saw.” From an obese self-mutilating man who is forced to crawl through a razor wire maze if he hopes to survive, to a heroin addict who has to cut a key out of a man’s stomach lest her head be split in half by a reverse bear trap, one has to wonder at the creativity of the scenarios. But the film’s stilted plot progression, amateurish acting and embarrassing dialogue are several of the reasons to avoid it.