LOS ANGELES — Scare-seeking audiences preferred the family-friendly “Goosebumps” over the gothic horror of Guillermo del Toro’s haunted house pic “Crimson Peak” two weekends out from Halloween.

Sony’s “Goosebumps,” based on the popular book series, earned $23.5 million out of the gates to take the first-place spot, while del Toro’s “Crimson Peak” languished at fourth with $12.8 million.

“Goosebumps” also managed to beat “The Martian” by a hair, pushing Ridley Scott’s space adventure to the second-place spot for the first time in its three-week run with $21.5 million.

Starring Jack Black as author R.L. Stine, “Goosebumps” cost a reported $58 million to produce. Audiences, 59 percent of whom were under the age of 25, gave the film a promising “A” CinemaScore, and reviews have been mostly favorable for the PG-rated pic.

“It’s set up so well for not only this weekend, but for the rest of the fall,” said Rory Bruer, Sony’s president of worldwide distribution. “The word of mouth is just terrific. I think we were able to convey how much fun the film is for the entire family, no matter what their age.”

The Halloween-timing didn’t necessarily help “Crimson Peak,” though. The Legendary film, distributed by Universal, failed to attract a significant audience in its debut. Those who did turn out gave the film a lousy B- CinemaScore.

It’s one of del Toro’s lowest wide openings; 1997’s “Mimic” earned only $7.8 million in its first weekend in theaters.

Also on the lower end, Steven Spielberg’s well-received cold-war thriller “Bridge of Spies,” meanwhile, debuted in third place with $15.4 million from 2,811 theaters.