Proper regulation of the intracellular ion concentration is essential to maintain life and is achieved by ion transporters that transport their substrates across the membrane in a strictly regulated manner. MgtE is a Mg(2+) transporter that may function in the homeostasis of the intracellular Mg(2+) concentration. A recent crystallographic study revealed that its cytosolic domain undergoes a Mg(2+)-dependent structural change, which is proposed to gate the ion-conducting pore passing through the transmembrane domain. However, the dynamics of Mg(2+) sensing, i.e., how MgtE responds to the change in the intracellular Mg(2+) concentration, remained elusive. Here we performed molecular dynamics simulations of the MgtE cytosolic domain. The simulations successfully reproduced the structural changes of the cytosolic domain upon binding or releasing Mg(2+), as well as the ion selectivity. These results suggested the roles of the N and CBS domains in the cytosolic domain and their respective Mg(2+) binding sites. Combined with the current crystal structures, we propose an atomically detailed model of Mg(2+) sensing by MgtE.