<p>Mg-doped epitaxial GdN thin films with various Mg-doping levels were grown using molecular beam epitaxy, and their electric, magnetic and optoelectronic properties were investigated. Characterisation through X-ray diffraction technique showed that there is no systematic variation in the crystallographic structure of the films with increasing level of Mg-doping, for Mg concentrations up to ~5 x 10¹⁹ atoms/cm³. However, from Mg concentration ~2 x 10²⁰ atoms/cm³ a clear deterioration in the crystalline quality was seen. We observed an increase in the resistivity of the films from 0.002 Ωcm to 600 Ωcm at room temperature when increasing the Mg-doping level, resulting in semi-insulating films for Mg concentrations up to 5 x 10¹⁹ atoms/cm³. Hall effect measurements revealed that the n-type carrier concentration was reduced from 7 x 10²⁰ cm⁻³ for an undoped film to 5 x 10¹⁵ cm⁻³ for a heavily doped film, demonstrating electron compensation in GdN via Mg-doping. Magnetic measurements exhibited substantial contrasts in the films, with a Curie temperature of ~70 K for an undoped film reduced down to ~50 K for a heavily Mg-doped film. Finally, photoconductivity measurements showed that films with higher level of Mg-doping displaying a faster photoconductive response. The decay time of 13000 s for an undoped film was reduced to 170 s with a moderate level of Mg-doping, which raises the possibility of Mg impurities providing hole traps that act as recombination centres in n-type GdN films.</p>