SummaryThe ability of excess Mg2+ to compensate the absence of cell wall related genes in Bacillus subtilis has been known for a long time, but the mechanism has remained obscure. Here, we show that the rigidity of wild‐type cells remains unaffected with excess Mg2+, but the proportion of amidated meso‐diaminopimelic (mDAP) acid in their peptidoglycan (PG) is significantly reduced. We identify the amidotransferase AsnB as responsible for mDAP amidation and show that the gene encoding it is essential without added Mg2+. Growth without excess Mg2+ causes ΔasnB mutant cells to deform and ultimately lyse. In cell regions with deformations, PG insertion is orderly and indistinguishable from the wild‐type. However, PG degradation is unevenly distributed along the sidewalls. Furthermore, ΔasnB mutant cells exhibit increased sensitivity to antibiotics targeting the cell wall. These results suggest that absence of amidated mDAP causes a lethal deregulation of PG hydrolysis that can be inhibited by increased levels of Mg2+. Consistently, we find that Mg2+ inhibits autolysis of wild‐type cells. We suggest that Mg2+ helps to maintain the balance between PG synthesis and hydrolysis in cell wall mutants where this balance is perturbed in favor of increased degradation.