International audienceThe physical origin of the near-ultraviolet Mg ii emission remains an underexplored domain, unlike more typical emission lines that are detected in the spectra of star-forming galaxies. We explore the nebular and physical properties of 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 Mg ii λλ2796, 2803 resonant doublet, from absorption to emission. We present a study on the main drivers for the detection of Mg ii emission in galaxy spectra. By exploiting photoionization models, we verified that the emission-line ratios observed in galaxies with Mg ii in emission are consistent with nebular emission from Hi...