Stress evolution during molecular-beam epitaxy of AIN films was monitored with in situ curvature measurements. Changes in the growth rate produced large stress variations, with more tensile stress observed at higher growth rates. For example, at a growth temperature of 750 degrees C the instantaneous steady-state stress in films with similar grain sizes varied from -0.15 GPa at a growth rate of 90 nm/h, to approximately 1.0 GPa at a growth rate of 300 nm/h. To explain these results, we develop a kinetic model of stress evolution that describes both tensile and compressive mechanisms. The tensile component is based on a mechanism which is proposed here as an inherent feature of grain-boundary formation. The compressive component is based on our recent model of atom insertion, driven by the excess chemical potential of surface adatoms that is created by the growth flux. The combined model predicts that the stress is largely governed by the competition between tensile and compressive mechanisms, which can be conveniently described with a single parameter, alpha. The limiting values alpha -> 0 and alpha ->+infinity correspond to previous models of compressive and tensile stresses, respectively. (c) 2005 American Institute of Physics.