We demonstrate the generation and optical control of ultrashort high-coherence electron pulses. The free-electron quantum state is phase-modulated in the longitudinal and transverse dimensions, and the formation of attosecond electron pulse trains is quantitatively probed.