A transmission electron microscopy of pyramidal inversion domains induced by Mg doping in MOVPE and bulk GaN is presented. Based on high resolution observations and EDX analysis, two atomic models are proposed for the Mg-rich (0001) inversion domain boundaries. These structural defects appearing for Mg concentrations in the 10(19) cm(-3) range are shown to be possible origins for the auto-compensation and the blue luminescence.