An algorithm, called RATTLE, for integrating the equations of motion in molecular dynamics calculations for molecular models with internal constraints is presented. The algorithm is similar to SHAKE, which is one of the standard methods for performing such calculations. RATTLE calculates the positions and velocities at the next time from the positions and velocities at the present time step, without requiring information about the earlier history. Like SHAKE, it is based on the Verlet algorithm and retains the simplicity of using Cartesian coordinates for each of the atoms to describe the configuration of a molecule with internal constraints. RATTLE guarantees that the coordinates and velocities of the atoms in a molecule satisfy the internal constraints at each time step. RATTLE has two advantages over SHAKE. On computers of fixed precision, it is of higher precision than SHAKE. Since it deals directly with the velocities, it is easier to modify RATTLE for use with the recently developed constant temperature and constant pressure molecular dynamics methods and with the nonequilibrium molecular dynamics methods that make use of rescaling of the atomic velocities.