We investigated the optical and electrical quality of Mg-doped In x Ga 1− x N (0⩽ x⩽0.045) grown by metalorganic chemical vapor deposition with different In and Mg contents. The band edge emission of p- In x Ga 1− x N layer depended on the Mg incorporation. The emission intensity of InGaN band edge peak was drastically reduced with increasing Mg incorporation, indicating that the concentration of nonradiative recombination centers increased with Mg doping concentration in InGaN layer. Mg-related emission of p-In x Ga 1− x N was changed from the shallow acceptor level to deep acceptor level as Mg concentration increased. Additionally, photoluminescence spectra showed that the band to acceptor emission energy E(e −, A 0) decreased with increasing In composition under the same Mg concentration of 2×10 19/cm 3. The activation energy of Mg obtained from PL spectra is reduced from 170 to 123 meV with increasing In content. Although the intensity of InGaN band edge emission and the donor–acceptor pair emission drastically decreased with increasing Mg concentration, the hole concentration increased up to 2.5×10 18/cm 3 with Mg concentration for p-In 0.045Ga 0.955N.