Fantasma vs. espectro vs. espíritu
The words 'fantasma', 'espectro', and 'espíritu' in Spanish all broadly pertain to notions of the ghostly or spectral. However, they are used in slightly different contexts and carry subtly distinctive meanings.
Fantasma
This word directly translates to 'ghost' and is typically used to refer to the soul or spirit of a deceased person that is believed to be capable of appearing in a visible form or otherwise manifesting itself to the living.
Vimos un fantasma en la vieja mansión abandonada.
(We saw a ghost in the old abandoned mansion.)
Ana dice que su casa está encantada por el fantasma de un antiguo residente.
(Ana says her house is haunted by the ghost of a former resident.)
Espectro
'Espectro' can also mean 'ghost', but it is more often used in a broader sense to denote any kind of apparition, phantom, or shadowy figure, not necessarily related to a deceased person. It can also refer to a wide range or spectrum in scientific terms.
Esto se manifiesta en todo el espectro de luz visible.
(This is manifested across the entire spectrum of visible light.)
El espectro apareció en el oscuro pasillo del castillo.
(The specter appeared in the dark hallway of the castle.)
Espíritu
Roughly translated as 'spirit', this term goes beyond merely denoting ghosts. It can refer to the soul or inner character of a human being, or the immaterial part of any living being. It's also used in religious and philosophical contexts.
El espíritu humano es increíblemente resistente.
(The human spirit is incredibly resilient.)
El espíritu de la ley es más importante que la letra.
(The spirit of the law is more important than the letter.)
Puedo sentir el espíritu de mi abuela cuidándome desde el cielo.
(I can feel my grandmother's spirit looking after me from heaven.)
Summary
While all three words share themes of phantoms and spirits, there are clear differences: 'fantasma' directly refers to ghosts, traditionally those of deceased people; 'espectro' narrates about any ethereal figure or apparitions and also represents range in a scientific way; 'espíritu' propounds not only spiritual but emotional and character aspects of living beings.