Mg2+ serves as an essential cofactor for numerous enzymes and its levels are tightly regulated by various Mg2+ transporters. Here, we analyzed Caenorhabditis elegans strains carrying mutations in genes encoding cyclin M (CNNM) Mg2+ transporters. We isolated inactivating mutants for each of the five Caenorhabditis elegans cnnm family genes, cnnm-1 through cnnm-5. cnnm-1; cnnm-3 double mutant worms showed various phenotypes, among which the sterile phenotype was rescued by supplementing the media with Mg2+. This sterility was caused by a gonadogenesis defect with severely attenuated proliferation of germ cells. Using this gonadogenesis defect as an indicator, we performed genome-wide RNAi screening, to search for genes associated with this phenotype. The results revealed that RNAi-mediated inactivation of several genes restores gonad elongation, including aak-2, which encodes the catalytic subunit of AMP-activated protein kinase (AMPK). We then generated triple mutant worms for cnnm-1; cnnm-3; aak-2 and confirmed that the aak-2 mutation also suppressed the defective gonadal elongation in cnnm-1; cnnm-3 mutant worms. AMPK is activated under low-energy conditions and plays a central role in regulating cellular metabolism to adapt to the energy status of cells. Thus, we provide genetic evidence linking Mg2+ homeostasis to energy metabolism via AMPK.