Mg-doped AlxGa1-xN epilayers with Al content up to 0.27 were grown on sapphire substrates by metalorganic chemical vapor deposition (MOCVD). p-type conduction in these alloys has been achieved, as confirmed by variable temperature Hall-effect measurements. Emission lines of band-to-impurity transitions of free electrons with neutral Mg acceptors as well as localized excitons have been observed in the p-type AlxGa 1-xN alloys. The Mg acceptor activation energies EA were deduced from photoluminescence spectra and were found to increase with Al content and agreed very well with those obtained by Hall measurements. From the measured activation energy as a function of the Al content, EA versus x the resistivity of AlxGa1-xN alloys with high Al contents can be deduced. Our results thus indicated that alternative methods for acceptor activation in AlGaN alloys with high Al contents must be developed. Our results have also shown that PL measurements provide direct means of obtaining EA, especially where this cannot be obtained accurately by electrical methods due to high resistance of Mg-doped AlxGa 1-xN alloys with high Al content.