Mg ion conductors, MgAl2O4 and MgZr4(PO4)6, were prepared by solid state reaction. Their electrical properties were measured and their application in electrochemical sensors for on-line determination of Mg in molten Al in the refining process and alloying process was examined. The activation energies for Mg ion conduction in MgAl2O4 and MgZr4(PO4)6 are 2.08 eV and 1.7 eV, respectively. The sensors have been found to respond rapidly to the change of Mg content in molten aluminium around 1000 K.