Transmission electron microscopy has been used to study defects formed in Mg-doped GaN crystals. Three types of crystals have been studied: bulk crystals grown by a high pressure and high temperature process with Mg added to the Ga solution and two types of crystals grown by metal-organic chemical vapor deposition (MOCVD) where Mg was either delta-doped or continuously doped. Spontaneous ordering was observed in bulk crystals. The ordering consists of Mg rich planar defects on basal planes separated by 10.4 nm and occurs only for growth in the N to Ga polar direction (000 N polarity). These planar defects exhibit the characteristics of stacking faults with a shift vector of a 1/3 [1 00] +c/2 but some other features identify these defects as inversion domains. Different type of defects were formed on the opposite site of the crystal (Ga to N polar direction), where the growth rate is also an order of magnitude faster compared to the growth with N-polarity. These defects are three-dimensional: pyramidal and rectangular, empty inside with Mg segregation on internal surfaces. The same types of defects seen for the two growth polarities in the bulk crystals were also observed in the MOCVD grown GaN samples with Mg delta doping, but were not observed in the crystals where Mg was added continuously.