Using density functional theory, we study the magnetic stability of the Ga1−xMnxN alloy system. We show that unlike Ga1−xMnxAs, which shows only ferromagnetic (FM) phase, Ga1−xMnxN can be stable in either FM or antiferromagnetic phases depending on the alloy concentration. The magnetic order can also be altered by applying pressure or with charge compensation. A unified model is used to explain these behaviors.The discovery of ferromagnetism in Mn-containing III-V semiconductors has attracted significant attention in the last decade because the interesting combination of semiconductor electronics and metallic ferromagnetism creates great potential for developing functional devices that manipulate spin, as well as charge. Among the materials that have been investigated, GaMnN is one of the most interesting systems. On one hand, original theoretical predictions suggest that high T c ferromagnetism can be achieved in the GaMnN alloy [1], which has resulted in an extensive experimental, as well as theoretical, study of its physical properties. On the other hand, available experimental data often contradict each other. Some reports show that high T c ferromagnetism is achievable in this system [2,3,4,5]; others show that the magnetic coupling of the Mn ions in GaMnN is actually antiferromagnetic (AFM) [6]. The exact nature of the magnetism observed in this system is also still under debate [7,8,9]. Some groups suggested that the observed ferromagnetism could be due to secondary phases generated during growth, and that GaMnN is a spin glass system [8]. Other groups argue that no secondary phase is observed in their single-crystal GaMnN samples that show ferromagnetism [9]. There are also discussions about whether the relevant Mn 3d state has d 4 or d 5 + h character, or whether the d levels are localized in the bandgap or inside the valence band [10].Although many of the issues are still under intensive study, recent ab initio band structure and total energy calculations [11,12,13] seem to agree that Mn 3d levels are located in the gap, and that the interaction between substitutional Mn ions is ferromagnetic (FM) at low Mn concentration. Because previous ab initio studies also find that pure MnN has an AFM ground state [14], an interesting question was raised about how the magnetic and electronic properties of Ga 1−x Mn x N evolve as a function of the Mn concentration x. Furthermore, it is now well known that the ferromagnetism observed in Mn-containing GaAs is caused by holes in the host valence-band-derived states. It would be important to understand how the mechanism changes in Mn-containing GaN, where the holes are created in the Mn d bands.In this paper, using ab initio band structure and total energy methods, we study the magnetic properties of Ga 1−x Mn x N in the low and high Mn concentration regimes. We also study the effects of pressure and charge compensation on the magnetic properties of this system. We show that unlike in GaMnAs, where p-d coupling induced level splitting at the valence band maximum (VBM)...