The transient receptor potential melastatin 7 (trpm7) channel kinase is a primary regulator of magnesium homeostasis in vitro. Here we show that trpm7 is an important regulator of cation homeostasis as well as kidney function in vivo. Using zebrafish trpm7 mutants, we show that early larvae exhibit reduced levels of both total magnesium and total calcium. Accompanying these deficits, we show that trpm7 mutants express higher levels of stanniocalcin 1 (stc1), a potent regulator of calcium homeostasis. Using transgenic overexpression and morpholino oligonucleotide knockdown, we demonstrate that stc1 modulates both calcium and magnesium levels in trpm7 mutants and in the wild type and that levels of these cations are restored to normal in trpm7 mutants when stc1 activity is blocked. Consistent with defects in both calcium and phosphate homeostasis, we further show that trpm7 mutants develop kidney stones by early larval stages and exhibit increased levels of the anti-hyperphosphatemic factor, fibroblast growth factor 23 (fgf23). Finally, we demonstrate that elevated fgf23 expression contributes to kidney stone formation by morpholino knockdown of fgf23 in trpm7 mutants. Together, these analyses reveal roles for trpm7 in regulating cation homeostasis and kidney function in vivo and implicate both stc1 and fgf23 in these processes.