Luminescence and thermally stimulated luminescence (TL) of BeO:Mg crystals are studied at T = 6-380 K. The TL glow curves and the spectra of luminescence (1.2-6.5 eV), luminescence excitation, and reflection (3.7-20 eV) are obtained. It is found that the introduction of an isovalent magnesium impurity into BeO leads to the appearance of three new broad luminescence bands at 6.2-6.3, 4.3-4.4, and 1.9-2.6 eV. The first two are attributed to the radiative annihilation of a relaxed near-impurity (Mg) exciton, the excited state of which is formed as a result of energy transfer by free excitons. The impurity VUV and UV bands are compared with those for the intrinsic luminescence of BeO caused by the radiative annihilation of self-trapped excitons (STE) of two kinds: the band at 6.2-6.3 eV of BeO:Mg is compared with the band at 6.7 eV (STE1) of BeO, and the band at 4.3-4.4 eV is compared with the band at 4.9 eV (STE2) of BeO. In the visible region, the luminescence spectrum is due to a superposition of intracenter transitions in an impurity complex including a magnesium ion. The manifestation of X-ray induced luminescence bands at T = 6 K in BeO:Mg indicates their excitation during band-to-band transitions and in recombination processes. The energy characteristics of the impurity states in BeO:Mg are determined; the effect of the isovalent impurity on the fluctuation rearrangement of the BeO:Mg structure in the thermal transformation region of STE1 →STE2 is revealed.