We demonstrate the quantized transfer of photon energy and transverse momentum to a high-coherence electron beam. In an ultrafast transmission electron microscope, a three-dimensional phase modulation of the electron wavefunction is induced by transmitting the beam through a laser-illuminated thin graphite sheet. This all-optical free-electron phase space control results in high-purity superpositions of linear momentum states, providing an elementary component for optically programmable electron phase plates and beam splitters.