The superposition of quantum states drives motion on the atomic and subatomic scales, with the energy spacing of the states dictating the speed of the motion. In the case of electrons residing in the outer (valence) shells of atoms and molecules which are separated by electronvolt energies, this means that valence electron motion occurs on a subfemtosecond to few-femtosecond timescale (1 fs = 10−15 s). In the absence of complete measurements, the motion can be characterized in terms of a complex quantity, the density matrix. Here we report an attosecond pump–probe measurement of the density matrix of valence electrons in atomic krypton ions1. We generate the ions with a controlled few-cycle laser field2 and then probe them through the spectrally resolved absorption of an attosecond extreme-ultraviolet pulse3, which allows us to observe in real time the subfemtosecond motion of valence electrons over a multifemtosecond time span. We are able to completely characterize the quantum mechanical electron motion and determine its degree of coherence in the specimen of the ensemble. Although the present study uses a simple, prototypical open system, attosecond transient absorption spectroscopy should be applicable to molecules and solid-state materials to reveal the elementary electron motions that control physical, chemical and biological properties and processes.