Based on first-principles spin-density functional calculations, we investigate the magnetic properties of Mn-doped GaN. We find that the magnetic interaction between two Mn ions has a short-range nature, effective for Mn-Mn distances up to about 7 angstrom, and it favors the ferromagnetic coupling via the double exchange mechanism. As the Mn atom interacts with more Mn atoms by introducing additional Mn atoms, the superexchange coupling is enhanced, stabilizing the antiferromagnetic state. In Mn-doped GaN, we find that Ga vacancies are energetically more stable near the Mn layer than in the bulk region due to the charge transfer from the Mn to the Ga vacancy, which may give rise to p-type conductivity. (c) 2006 Elsevier B.V. All rights reserved.