Polyanionic and featuring a potentially chelating polyphosphate group, ATP binds metal cations with high affinity. The binding constant for  is ().  The binding of a divalent cation, almost always magnesium, strongly affects the interaction of ATP with various proteins. Due to the strength of the ATP-Mg interaction, ATP exists in the cell mostly as a complex with  bonded to the phosphate oxygen centers.
A second magnesium ion is critical for ATP binding in the kinase domain. The presence of Mg regulates kinase activity.   It is interesting from an RNA world perspective that ATP can carry a Mg ion which catalyzes RNA polymerization.