Zilpha Keatley Snyder, who mined memories of little demons at the foot of her childhood bed to spin tales of wonder, mystery and suspense that beguiled two generations of children and young adults in nearly 50 books, died on Oct. 7 in San Francisco. She was 87.

The cause was complications of a stroke, said her publisher, Simon & Schuster.

Most of Ms. Snyder’s books were intended for readers 9 to 13 and delved into subjects like witchcraft, murder and dysfunctional families. She mixed realism and the supernatural, and her stories often had endings that could be interpreted from either viewpoint. Her plots were tight, and her protagonists were often vital, thoughtful, courageous females.

Her books almost always received excellent reviews. Referring to her 1967 book, “The Egypt Game,” Zena Sutherland wrote in The Bulletin of the Center for Children’s Books, “It is strong in characterization, the dialogue is superb, the plot is original.”

“The Egypt Game” tells of two girls, April and Melanie, who turn a vacant lot into ancient Egypt for their fantasy games. But play turns nasty when a killer stalks April. It was named a Newbery Honor Book, as were two of Ms. Snyder’s other books.