We have studied the evolution of stress and microstructure of compositionally graded Al1-xGaxN (0 ≤ x ≤ 1) buffer layers on (111) Si substrates with varying thicknesses. In-situ stress measurements reveal a tensile-to-compressive stress transition that occurs near the half-thickness in each buffer layer. Cross-sectional transmission electron microscopy (TEM) shows a significant reduction in threading dislocation (TD) density in the top half of the buffer layer, suggesting that the compressive stress enhances the threading dislocation annihilation. The composition of the buffer layers varies linearly with thickness, as determined by X-ray energy dispersive spectrometry (XEDS). The composition grading-induced compressive stress offsets the tensile stress introduced by microstructure evolution, thus yielding a tensile-to-compressive stress transition at x ≈ 0.5.