High-resolution x-ray diffraction, in surface symmetric, skew symmetric, and grazing incidence in-plane diffraction geometries, has been used to investigate the effect of an AlN interlayer between micron thick GaN and AlxGa1-xN layers grown by metalorganic vapor phase epitaxy on basal plane sapphire. No change is found in the tilt mosaic (threading screw dislocation density) with thickness or Al fraction x of the upper layer. A linear increase in the twist mosaic (threading edge dislocation density) was observed as a function of interlayer thickness and x. For all samples the twist mosaic of the AlGaN was significantly greater, by at least a factor of two, than that of the GaN layer. With increasing interlayer thickness the in-plane lattice parameter of the AlGaN decreased. The results are explained in terms of extra threading edge dislocations resulting from relaxation at the GaN/AlN interface. (C) 2003 American Institute of Physics.