A series of Al0.47Ga0.53N/GaN heterostructures with different AlN interlayer thicknesses ranging from 1nm to 50nm has been examined. It was found that when the interlayer thickness is greater than ∼5nm, it becomes possible to grow 250nm of Al0.47Ga0.53N without cracking. The interlayers are then believed to be sufficiently relaxed to place the AlGaN under compressive strain. The mechanisms for this relaxation have been studied using high angle annular dark field (HAADF) imaging, conventional transmission electron microscopy (TEM), energy-filtered TEM (EFTEM) and electron energy loss spectroscopy (EELS). It is found that relaxation takes place through both the small-scale cracking of the interlayer and the generation of misfit dislocations at the GaN/AlN interface. EELS and EFTEM have been used to probe the Al and Ga content of both the material filling the interlayer cracks, and the interlayer itself. This chemical analysis suggests Ga-rich AlGaN areas inside the interlayer cracks and also significant compositional variations in defect-free interlayer regions. It is observed that relaxation by the generation of misfit dislocations results in an increase in the threading dislocation density of the AlGaN layer, in part due to the bending up of misfit dislocations at crack walls.