By Terry Pratchett. HarperCollins. 278 pp. $16.99 It's a staple of children's literature: A plucky young girl discovers that she's different and special and goes off to learn the ways of her kind. Tiffany Aching first appeared in last year's The Wee Free Men as a brave, cunning, frying-pan-wielding 9-year-old from the chalk country who learns that she's destined to be a witch, as her grandmother was before her. In this sequel, set two years later, she leaves home to become an apprentice to Miss Level, an older witch with two bodies and one mind. As before, comic relief and legwork arrive courtesy of Tiffany's allies, the Nac Mac Feegle or "Pictsies" -- tiny, super-strong blue elves with Scottish accents and Yosemite Sam attitudes. British fantasy author Terry Pratchett has set Tiffany's adventures on Discworld, the site of his novels for grown-ups; older readers may recognize a few familiar characters.

Pratchett's a lively writer who can rarely resist a good gag, and he's got a lot of them. But the thematic underpinnings that made The Wee Free Men such a pleasure to read turn sour here. The point of the first book was that witches are able to manipulate reality mostly because they observe things carefully and think about them clearly -- what Pratchett calls "First Sight and Second Thoughts." (Well, that is something that makes people different and special.) In A Hat Full of Sky, though, witches spend a great deal more time riding broomsticks and casting spells. That's odd, since Pratchett establishes that their main duty is to bustle around taking care of the sick, the poor and the lonely -- sort of a cross between country doctors and old-fashioned vicars. And Tiffany's wits have little to do with the hocus-pocus that resolves the story here.

The main plot of A Hat Full of Sky concerns Tiffany being possessed by a "hiver," a hermit-crab-like entity that moves into its victim's consciousness and sets its host body's id loose, making it act on suppressed desires and absorbing its original personality into a shared hive-mind. (There is a rather labored chain of beekeeping imagery that accompanies this idea.) Under the hiver's thrall, Tiffany becomes a vicious, show-offy brat, stealing money from the helpless, turning people into frogs and much worse. Once she reasserts her personality, though, she's almost literally allowed to get away with murder: The harm she's done by letting her will become law is brushed aside or, in one case, converted into a blessing by the Nac Mac Feegle. ("It's an unfair world, child," Mistress Weatherwax tells her. "Be glad you have friends.") The moral, effectively, is that it's easier to get forgiveness than permission.

Pratchett is often very funny. His narrative voice is entertainingly flippant, and his gags have a vaudevillian sense of comic timing, as when Tiffany visits a souvenir shop in a flyspeck of a town called Twoshirts: "The little old lady behind the counter called her 'young lady' and said that Twoshirts was very popular later in the year, when people came from up to a mile around for the Cabbage Macerating Festival."

Witches, in Pratchett's Discworld, have witch trials in the same sense that sheep farmers have sheepdog trials -- they get together and show off their latest tricks. A wizard in the back room of a wand-and-potion shop has a mug labeled, "YOU DON'T HAVE TO BE MAGIC TO WORK HERE BUT IT HELPS!"

Still, a book about a young magician in training can't avoid comparisons to the Harry Potter series. Pratchett's jokes aren't as resonant, and Miss Level's cottage is no Hogwarts. Even J.K. Rowling's minor characters have psychological depth, and her teachers are so fully developed that the Potter books double as stories about pedagogy. Here, though, everyone besides Tiffany is a two-dimensional cipher -- the senior witches, in particular, are nearly interchangeable good-hearted eccentrics. Harry grows up and changes from volume to volume, but 11-year-old Tiffany thinks and acts almost exactly like her 9-year-old self, which is fairly unusual where actual children are concerned.

After a strong beginning, A Hat Full of Sky becomes frustratingly sloppy. The Pictsies, Pratchett has established, believe that they are already dead and that the world they inhabit, full of booze and adventure, is Heaven -- so it doesn't quite click when they talk fearfully about dying, or offer to accompany Tiffany into the realm of Death. They drive the hiver into submission by beating it up inside Tiffany's mind until the hills to which she's mystically connected rise up within her subconscious and rescue her, and if you don't think that makes much sense, you're right. And the conclusion is a mess -- a congeries of vague metaphysics about death and endless deserts and "the world getting back into line," followed by a rhapsodic ending so sappy you can practically hear the music behind the credits. It doesn't feel as if Tiffany has earned her victory, or as if Pratchett is doing justice to his inquisitive young heroine. *

Douglas Wolk writes about comic books for Publishers Weekly and the Believer. His book, "James Brown Live at the Apollo," will be published in August.