Before spawning a spiffy sequel in 2016, James Wan’s surprise 2013 horror hit “The Conjuring” had already birthed a far inferior spin-off, “Annabelle” (2014), about the earlier history of a possessed and dangerous doll featured in the earlier movie. Now there’s a prequel to the spin-off. The whole process might well make your head spin—and not with pleasure, since the plot devised for “Annabelle: Creation” by returning screenwriter Gary Dauberman leaves a lot to be desired. Nonetheless canny direction by David F. Sandberg (“Lights Out”) manages to wring more chills from the material than it deserves, though the script’s incoherence makes the movie feel like a random assemblage of cunningly crafted horror tropes rather than an intelligible narrative.

Still, one must make some effort to disentangle the plot. A prologue, set in the mid-1940s, shows toymaker Samuel Mullins (Anthony LaPaglia) fashioning the doll for his sweet seven-year old daughter Annabelle (Samara Lee). Unfortunately, the girl is killed in a roadside accident as Samuel and his wife Esther (Miranda Otto) look on in horror.

Twelve years later, around 1957, the remote Mullins farm becomes a foster home for a group of six girls from St. Eustace, a recently closed Catholic orphanage. Sister Charlotte (Stephanie Sigman) accompanies them, and among the orphans are two close friends, cheery Linda (Lulu Wilson) and gloomy Janice (Talitha Bateman), who wears a leg brace as a result of a bout of polio. They’re greeted by Samuel, a stiff, unemotional man, but Esther is confined to bed as a result of some unexplained malady and remains hidden in the master bedroom. The four older girls take a pleasant dorm-style room on the second floor, while Janice and Linda move into a smaller one, which is filled with half-finished doll torsos. Janice, moreover, is shown by Mullins how to use an automatic chair lift that will carry her up and down the long stairwell.

Brooding Samuel gives his guests the run of the place, though he doesn’t seem at all happy at their presence. He has only one rule: they cannot enter one second-floor room. We will soon learn that it was Annabelle’s bedroom, kept as it was when the girl died. Supposedly it’s locked, but Janice, antsy while the others play outside, enters it without any difficulty, and there encounters the doll, put away inside a closet. Creepily, it seems able to move, and before long will start doing all sorts of malevolent things, menacing many of the girls but especially targeting Janice. Long story short (and beware of a spoiler here), the doll is an instrument of the specter of the deceased Annabelle, who was restored to a semblance of life in a compact her grieving parents made with the devil, but was actually possessed by some demonic force, which is now utilizing the girl’s spirit—and the doll—for its evil purposes.

This back story raises a fundamental issue: if Ma and Pa Mullins were aware of the malevolent presence in their house, why would they invite a tasty passel of prospective victims to stay there, and be so cavalier about it? (There’s an attempt at an explanation, but it’s beyond idiotic.)

Even if one is willing to swallow that, however, a larger problem emerges with Dauberman’s decision to throw any semblance of logic or coherence to the wind to construct a chain of horror-movie clichés that quickly take on a grab-bag feel. At one point, for example, a scary-looking scarecrow kept in an adjacent shed is animated and threatens the girls, then promptly disappears. At another Linda is menaced in her room by the doll and the slithering black entity possessing it, but nothing follows from it. Most absurdly, there’s a long sequence in which Janice is stalked by the creature at night, literally thrown out of her chairlift to the ceiling and then dropped down to the floor. She’s screaming all the time, but nobody hears her; they sleep contently through the entire business. To add to the imbecility of it all, Janice returns to the house a few days later in a wheelchair to convalesce. (A similar sequence in the barn will occur later, and once again it will take forever for anyone to become aware of the girl’s shrieking.) All these scenes, and many others, are accompanied by dialogue so ludicrous that you have to presume it’s intended to be taken as a joke: Samuel, and especially the obtuse Sister Charlotte, must be the dimmest bulbs in the pack to repeatedly say things like “Are you alright?” after the latest horror happens.

Of course, one shouldn’t blame Dauberman for everything. It’s possible that Sandberg simply invented some of the shock moments along the way to show off his talent at staging such stuff. And, in fact, he’s quite good at it, using light and shade, as well as sudden shifts in perspective, to excellent effect, amplified by Jennifer Spence’s evocative period production design, the atmospheric widescreen lensing of Maxime Alexandre, Michel Aller’s moody editing, and Benjamin Wallfisch’s score, which helps to generate tension while accentuating the gotcha moments. It must be noted, though, that one of the scare effects in Janice’s initial encounter with Annabelle involves the use of a sheet that bears a striking resemblance to an effect David Lowery also employs in “A Ghost Story,” and with far more powerful impact; the difference between mere craft and true vision has rarely been so clearly demonstrated.

Sandberg is also aided by the work of Bateman and Wilson, who make a surprisingly likable pair of young damsels in distress, especially in contrast to the rest of the cast, all of whom are frankly terrible, with Sigman, LaPaglia and Otto in particular coming off as almost comically bad. Of course, it’s hard to imagine anyone having done much with Dauberman’s lame plotting and insipid dialogue.

As usual in this sort of fare, “Annabelle: Creation” closes with a chain of climaxes, each dragging the picture on needlessly. But it finally closes with a postscript that takes the clumsy story to 1969 and the start of the first “Annabelle” movie. That provides at least some relief for a viewer anxious for this thread in the so-called “Conjuring Universe” to end: it means that at least a sequel to this prequel to the spin-off should not be forthcoming.