Materialist/ Naturalist believe that the only things that exist are what we can see with our eyes... basically the world that can be studied by science...so they DON'T BELIEVE in the "spiritual realm" (religion/God, devils, demons etc).
Therefore the sentence "haunted Europe's religious imagination" means that:
Spinoza's ideas were difficult for the religious groups in Europe to accept or ignore...his ideas contradicted their beliefs...made them feel uncomfortable...troubled them (haunted them like how ghosts haunt people in the movies).
"Religious imagination" suggests that Spinoza saw religion as something created by mankind's imagination...like how we can only imagine Unicorns🦄 or Dragons 🐉...just myths... there's no proof that they (God, the devil, angels) exist.