  Understanding the luminescence of GaN doped with erbium (Er) requires a
detailed knowledge of the interaction between the rare-earth dopant and the
nitride host, including intrinsic defects and other impurities that may be
present in the host material. We address this problem through a
first-principles hybrid density functional study of the structure, energetics,
and transition levels of the Er impurity and its complexes with N and Ga
vacancies, substitutional C and O impurities, and H interstitials in wurtzite
GaN. We find that, in the interior of the material, Er$_{\rm Ga}$ is the
dominant Er$^{3+}$ center with a formation energy of 1.55 eV; Er$_{\rm
Ga}$-$V_{\rm N}$ possesses a deep donor level at 0.61 eV which can assist in
the transfer of energy to the 4$f$-electron core. Multiple optically active
Er$^{3+}$ centers are possible in Er-doped GaN.
