We have tested a new algorithm to perform first-principles molecular dynamics simulations. This new scheme differs from the Car-Parrinello method and is based on the calculation of the self-consistent solutions of the Kohn-Sham equations at each molecular dynamics timestep, using a fast iterative diagonalization algorithm. We do not use a fictitious electron dynamics, and therefore the molecular dynamics timesteps can be considerably larger in our method than in the Car-Parrinello algorithm. Furthermore, the number of basis functions is variable, which makes this method particularly suited to deal with simulations involving a cell with variable shape and volume. Applications of this method to liquid Li offers results which are in excellent agreement with experiment and indicates that it is basically comparable in efficiency to the Car-Parrinello method.