We have studied the structure of 4 He droplets doped with magnesium atoms using density functional theory.We have found that the solvation properties of this system strongly depend on the size of the 4 He droplet. For small drops, Mg resides in a deep surface state, whereas for large-size drops it is fully solvated but radially delocalized in their interior. We have studied the 3s3p 1 P 1 ← 3s 21 S 0 transition of the dopant, and have compared our results with experimental data from laser-induced fluorescence ͑LIF͒. Line-broadening effects due to the coupling of dynamical deformations of the surrounding helium with the dipole excitation of the impurity are explicitly taken into account. We show that the Mg radial delocalization inside large droplets may help reconcile the apparently contradictory solvation properties of magnesium as provided by LIF and electronimpact ionization experiments. The structure of 4 He drops doped with two magnesium atoms is also studied and used to interpret the results of resonant two-photon-ionization ͑R2PI͒ and LIF experiments. We have found that the two solvated Mg atoms do not easily merge into a dimer, but rather form a weakly bound state due to the presence of an energy barrier caused by the helium environment that keeps them some 9.5 Å apart, preventing the formation of the Mg 2 cluster. From this observation, we suggest that Mg atoms in 4 He drops may form, under suitable conditions, a soft "foamlike" aggregate rather than coalesce into a compact metallic cluster. Our findings are in qualitative agreement with recent R2PI experimental evidence. We predict that, contrarily, Mg atoms adsorbed in 3 He droplets do not form such metastable aggregates.