Microstructural analysis was carried out to clarify the compositional dependence of the generation of dislocations in AlxGa1-xN on an underlying AlN layer grown by metalorganic vapor phase epitaxy. When the film thickness is less than 1.5 μm, the threading dislocation density (TDD) increases with decreasing AlN molar fraction. However, when the film thickness exceeds 1.5 μm, TDD becomes maximum at x around 0.5. The growth of AlGaN on a grooved AlN template is effective in reducing TDD for all AlN molar fractions. TDD in AlGaN, which is close to binaries such as GaN and AlN, is a few 107 cm–2, while for the intermediate composition with x around 0.5, TDD is still at mid 108 cm–2. The activation energy of Mg in AlGaN is found to show a strong Mg concentration dependence with a negative one-third power law in Al0.25Ga0.75N and Al0.5Ga0.5N as well as in GaN. Overdoping of Mg causes an increase in the activation energy for every composition; from this, the optimum Mg concentration for realizing the highest hole concentration can be deduced. (© 2009 WILEY-VCH Verlag GmbH & Co. KGaA, Weinheim)