  The physical origin of the near-ultraviolet MgII emission remains an
under-explored domain, contrary to more typical emission lines detected in the
spectra of star-forming galaxies. We explore the nebular and physical
properties for a sample of 381 galaxies between 0.70 < z < 2.34 drawn from the
MUSE Hubble Ultra Deep Survey. The spectra of these galaxies show a wide
variety of profiles of the MgII 2796,2803 resonant doublet, from absorption to
emission. We present a study on the main drivers for the detection of MgII
emission in galaxy spectra. By exploiting photoionization models we verified
that the emission-line ratios observed in galaxies with MgII in emission are
consistent with nebular emission from HII regions. From a simultaneous analysis
of MUSE spectra and ancillary HST information via spectral energy distribution
(SED) fitting, we find that galaxies with MgII in emission have lower stellar
masses, smaller sizes, bluer spectral slopes and lower optical depth than those
with absorption. This leads us to suggest that MgII emission is a potential
tracer of physical conditions not merely related to those of the ionized gas.
We show that these differences in MgII emission/absorption can be explained in
terms of a higher dust and neutral gas content in the interstellar medium (ISM)
of galaxies showing MgII in absorption, confirming the extreme sensitivity of
MgII to the presence of the neutral ISM. We conclude with an analogy between
the MgII doublet and the Ly-alpha line, due to their resonant nature. Further
investigations with current and future facilities, including JWST, are
promising as the detection of MgII emission and its potential connection with
Ly-alpha could provide new insights on the ISM content in the early Universe.
