Magnesium is essential for cellular life, but how it is homeostatically controlled still remains poorly understood. Here we report that members of CNNM family, which have been controversially implicated in both Mg2+ influx and efflux, selectively binds to the TRPM7 channel to mediate divalent cation entry. Co-expression of CNNMs with the channel markedly increased uptake of divalent cations, which is blocked by a channel-inactive mutant. Knockout of CNNM3 and CNNM4 significantly interfered with TRPM7-mediated divalent cation entry as monitored by Zn2+ and 25Mg-uptake assays and electrophysiology, while not affecting TRPM7’s surface protein level. Furthermore, we find that cellular overexpression of Phosphatases of Regenerating Liver (PRLs), a known CNNMs binding partner, stimulated TRPM7-dependent divalent cation entry and that CNNMs were required for this activity. We conclude that CNNMs function as regulatory subunits of the TRPM7 channel to achieve Mg2+ influx and that CNNMs also possess TRPM7-independent Mg2+ efflux activities to accomplish balanced control of cellular Mg2+ homeostasis.