The effects of thermal annealing in N2, O2, Ar or mixed gas ambient on the electrical and optical properties of metal-organic-chemical-vapor-deposition-grown Mg-doped p-type GaN were investigated by Hall effect and photoluminescence. A systematical study on optimizing annealing gas combination, time, and temperature for achieving high activation efficiency of Mg acceptors was conducted simultaneously. High hole concentration of 9.07 × 1017 cm-3 and low resistivity of 0.622 Ω-cm using the optimized annealing condition were achieved. In agreement with some previous studies, annealing in the mixed gas ambient of N2 and O2 provided significant improvements in activation efficiency of Mg acceptors compared with annealing in pure O2, N2, or Ar. The room- and low-temperature photoluminescence spectra measured from the samples annealed in N2-rich ambient showed significantly higher photoluminescence intensity at both 2.8- and 3.2-eV band transitions. Consistent with the study of others, the experimental results of this study indicated that when annealing in the mixed N2/O2 gas ambient O2 effectively helps activate Mg acceptors by releasing H from Mg-H complexes but also oxidizes GaN; it is likely that the presence of N2 is beneficial in reducing the formation of nitrogen vacancies.