Based on density functional theory calculations, we have studied the electronic structures and magnetic properties of passivated AlN nanowires (NWs) with Mg dopants. The calculated results show that double Mg atom doped passivated AlN NWs display ferromagnetic properties, and the total magnetic moment is 1.80 µB per 96-atom unit cell excluding the pseudohydrogen atoms. However, a couple of Mg atom doped bare AlN nanowire unit cells display anti-ferromagnetic (AFM) properties. Unequal properties of magnetic coupling in different Mg-doped AlN structures are due to the different localization and overlapping of impurity wave functions. It is also found that the ferromagnetic stability and Curie temperature of the passivated AlN NWs are much higher than those of bulk structures.