Enables the transfer of a solute or solutes from one side of a membrane to the other according to the reaction: ATP + H2O + Mg2+(out) = ADP + phosphate + Mg2+(in).
ATP phosphohydrolase (Mg2+-importing)