Effect of Mg doping on the properties of AlGaN layers gro wn on sapphire substrates by metal_organic chemical vapor deposition were studie d using x_ray diffraction and Raman scattering. When the doping of Mg was low, the E2 mode shifted to lower frequency and the full width half at maximum of the rocking curve and A1(LO) mode decreased. However, as the flow rate of CP2Mg increased ti ll the AlGaN was doped with a dose as high as 4×102/sup>cm-3, the quali ty of film de creased gradually and the E2mode shifted to higher frequency, indicat ing a compressive stress in the films. Finally, the relation between the Raman s hift and the stress alteration was described by Δσ=-0298+0562ΔE.