A study on the effect of high Mg doping on the microstructure of GaN grown on sapphire is presented. The tendency of Mg to induce a change in polarity is demonstrated. In metalorganic vapour phase epitaxy grown films, pyramidal and columnar inversion domains as well as local reversal of polarity are observed. A similar reversal of polarity is also observed in molecular beam epitaxy grown samples. As a consequence, Mg doping may open a way to control the polarity of GaN films and, therefore, to realise heterostructures with alternate polarities.