Dendritic spines mediate most excitatory inputs in the brain. Although it is clear that spines compartmentalize calcium, it is still unknown what role, if any, they play in integrating synaptic inputs. To investigate the electrical function of spines directly, we used second harmonic generation (SHG) imaging of membrane potential in pyramidal neurons from hippocampal cultures and neocortical brain slices. With FM 4-64 as an intracellular SHG chromophore, we imaged membrane potential in the soma, dendritic branches, and spines. The SHG response to voltage was linear and seemed based on an electro-optic mechanism. The SHG sensitivity of the chromophore in spines was similar to that of the parent dendritic shaft and the soma. Backpropagation of somatic action potentials generated SHG signals at spines with similar amplitude and kinetics to somatic ones. Our optical measurements of membrane potential from spines demonstrate directly that backpropagating action potentials invade the spines.