All known protein kinases, except CASK [calcium/calmodulin (CaM)-activated serine-threonine kinase], require magnesium ions (Mg(2+)) to stimulate the transfer of a phosphate from adenosine 5'-triphosphate (ATP) to a protein substrate. The CaMK (calcium/calmodulin-dependent kinase) domain of CASK shows activity in the absence of Mg(2+); indeed, it is inhibited by divalent ions including Mg(2+). Here, we converted the Mg(2+)-inhibited wild-type CASK kinase (CASK(WT)) into a Mg(2+)-stimulated kinase (CASK(4M)) by substituting four residues within the ATP-binding pocket. Crystal structures of CASK(4M) with and without bound nucleotide and Mn(2+), together with kinetic analyses, demonstrated that Mg(2+) accelerates catalysis of CASK(4M) by stabilizing the transition state, enhancing the leaving group properties of adenosine 5'-diphosphate, and indirectly shifting the position of the gamma-phosphate of ATP. Phylogenetic analysis revealed that the four residues conferring Mg(2+)-mediated stimulation were substituted from CASK during early animal evolution, converting a primordial, Mg(2+)-coordinating form of CASK into a Mg(2+)-inhibited kinase. This emergence of Mg(2+) sensitivity (inhibition by Mg(2+)) conferred regulation of CASK activity by divalent cations, in parallel with the evolution of the animal nervous systems.