In this work, we compare the defect structure in unintentionally doped and Si-doped AlN layers grown by metalorganic vapor phase epitaxy (MOVPE) on high-temperature annealed (HTA) sputtered AlN templates on sapphire substrates. Since the HTA process leads to a reduction of the in-plane lattice constant of the AlN layers, further homoepitaxial overgrowth results in compressively strained AlN layers. With increasing MOVPE-AlN layer thickness, strain relaxation takes place mostly by formation of dislocation half-loops of an irregular shape, which accumulate at the homoepitaxial MOVPE-AlN/HTA-AlN interface. We suggest that these dislocations nucleate at the layer surface and move down to the homoepitaxial interface at high temperatures. The formation of these irregular and hardly controllable defects can be avoided by introduction of Si-doping into the MOVPE-AlN layers. Si-doping enlarges the inclination of threading dislocation lines stemming from the HTA-AlN template, producing an alternative mechanism for strain relaxation.