Involved in chlorophyll biosynthesis; introduces a magnesium ion into protoporphyrin IX to yield Mg-protoporphyrin IX. ATP + H2O + Mg(2+) + protoporphyrin IX = ADP + 3 H(+) + Mg-protoporphyrin IX + phosphate Porphyrin-containing compound metabolism; chlorophyll biosynthesis. Belongs to the Mg-chelatase subunits D/I family.