Transmission electron microscopy (TEM) studies of defects in Al x Ga 1− x N layers with various Al mole fractions ( x=0.2, 0.4) and polarities were carried out. The samples were grown by ammonia molecular beam epitaxy on sapphire substrates and consisted of low-temperature AlN (LT-AlN) and high-temperature AlN (HT-AlN) buffer layers, a complex AlN/AlGaN superlattice (SL) and an Al x Ga 1− x N layer ( x=0.2, 0.4). It was observed that at the first growth stages a very high density of dislocations is introduced in both Al-polar and N-polar structures. Then, at the interface of the LT-AlN and HT-AlN layers half-loops are formed and the dislocation density considerably decreases in Al-polar structures, whereas in the N-polar structures such a behavior was not observed. The AlN/AlGaN superlattice efficiently promotes the bend and annihilation of threading dislocations and respectively the decrease of the dislocation density in the upper Al x Ga 1− x N layer with both polarities. The lattice relaxation of metal-polar Al 0.2Ga 0.8N was observed, while N-polar Al 0.2Ga 0.8N did not relax. The dislocation densities in the N-polar Al 0.2Ga 0.8N and Al 0.4Ga 0.6N layers were 5.5×10 9 cm −2 and 9×10 9 cm −2, respectively, and in metal-polar Al 0.2Ga 0.8N and Al 0.4Ga 0.6N layers these were 1×10 10 cm −2 and 6×10 9 cm −2, respectively. Moreover, from TEM images the presence of inversion domains (IDs) in N-polar structures has been observed. The widths of IDs varied from 10 to 30 nm. Some of the IDs widen during the growth of the AlN buffer layers. The IDs formed hills on the surface of the N-polar structures.