The transient receptor potential channel TRPM7 is a master regulator of the organismal balance of divalent cations that plays an essential role in embryonic development, immune responses, cell mobility, proliferation, and differentiation. TRPM7 is implicated in neuronal and cardiovascular disorders, tumor progression and has emerged as a new drug target. Here we use cryo-EM, functional analysis, and molecular dynamics simulations to uncover two distinct structural mechanisms of TRPM7 activation by a gain-of-function mutation and by the agonist naltriben, which show different conformational dynamics and domain involvement. We identify a binding site for highly potent and selective inhibitors and show that they act by stabilizing the TRPM7 closed state. The discovered structural mechanisms provide foundations for understanding the molecular basis of TRPM7 channelopathies and drug development.