The theoretical basis of the first-principles molecular dynamics introduced by Car and Parrinello [Phys. Rev. Lett. 55, 2471 (1985)] is investigated. We elucidate how the classical dynamics generated by the Car-Parrinello Lagrangian approximates efficiently the quantum adiabatic evolution of a system and discuss the role played by the spectrum of the eigenvalues of the Hamiltonian of Kohn and Sham [Phys. Rev. 140, A1133 (1965)]. A detailed characterization of the statistical ensemble sampled in the numerical simulation is given. By combining theoretical arguments and numerical results we demonstrate that the motion of the electronic variables is a superposition of a direct drag due to the ions and of high-frequency normal modes. By making a connection with the averaging methods of classical mechanics, we argue that whenever it is possible to get a large separation between the time scales of these modes and the ionic frequencies, the dynamics of the ions closely approximates that resulting from the adiabatic approximation. We introduce simple n-level models, easily amenable to analytic treatment, to add clarity and study the possible mechanisms of broken adiabaticity encountered in the actual calculations.