A recently characterized 'M-box' genetic switch from bacteria is proposed to directly sense cellular Mg2+ levels through the conformation of its newly synthesized RNA. This Mg2+-sensing riboswitch controls transcription termination in front of a Mg2+ transporter gene, thus introducing a new and direct level of genetic regulation to metal ion homeostasis.