Achieving time-domain control of quantum states with atomic-scale spatial resolution in nanostructures is a long-term goal in quantum nanoscience and spintronics. Here, we demonstrate coherent spin rotations of individual atoms on a surface at the nanosecond time scale, using an all-electric scheme in a scanning tunneling microscope (STM). By modulating the atomically confined magnetic interaction between the STM tip and surface atoms, we drive quantum Rabi oscillations between spin-up and spin-down states in as little as ~20 nanoseconds. Ramsey fringes and spin echo signals allow us to understand and improve quantum coherence. We further demonstrate coherent operations on engineered atomic dimers. The coherent control of spins arranged with atomic precision provides a solid-state platform for quantum-state engineering and simulation of many-body systems.