Manipulating the spin polarization of electron beams using light is highly desirable but exceedingly challenging, as the approaches proposed in previous studies using free-space light usually require enormous laser intensities. Here, we propose the use of a transverse electric optical near field, extended on nanostructures, to efficiently induce spin flips of an adjacent electron beam by exploiting the strong inelastic electron scattering in phase-matched optical near fields. Our calculations show that the use of a dramatically reduced laser intensity (∼ 10 12 W/cm 2 ) with a short interaction length (16 µm) achieves an electron spin-flip probability of approximately 12%. Intriguingly, the two spin components of an unpolarized incident electron beam-parallel and antiparallel to the electric field-are spin-flipped and inelastically scattered to different energy states, providing an analog of the Stern-Gerlach experiment in the energy dimension. Our findings are important for optical control of free-electron spins, preparation of spin-polarized electron beams, and applications as varied as in material science and high-energy physics.