Simple and effective measurement of Mg(2+) in the brain of living animals is of great physiological and pathological importance. In this study, we report a facile yet highly selective colorimetric method for effective sensing of cerebral Mg(2+). The method is based on rational design of surface chemistry of gold nanoparticles (Au-NPs) with functional molecules including 1,4-dithiothreitol (DTT) and cysteine, enabling the fine tuning of the surface chemistry of Au-NPs in such a way that the addition of Mg(2+) into the Au-NPs dispersion could selectively trigger the change of the dispersion/aggregation states of Au-NPs. The strong chelation interaction between Mg(2+) and the hydroxyls in 1,4-dithiothreitol and the co-existence of cysteine on the surface of Au-NPs could, on one hand, enable the selective colorimetric detection of Mg(2+) and, on the other hand, avoid the aggregation of Au-NPs induced by DTT itself. As a result, the addition of Mg(2+) into the dispersion of the Au-NPs containing both cysteine and DTT results in the changes in both the color and the UV-vis spectra of the Au-NPs dispersion. The signal readout shows a linear relationship of Mg(2+) within the concentration range from 1 μM to 40 μM with a detection limit of 800 nM (S/N = 3). Moreover, the assay demonstrated here is free from the interference of some physiological species commonly existing in rat brain. Although Ca(2+) could interfere with the detection of Mg(2+) because of its strong chelation with DTT, it could be selectively masked by masking agent (i.e., ethyleneglcol-bis (2-aminoethylether) tetraacetic acid). By combining the microdialysis technique, the basal dialysate level of Mg(2+) is determined to be 299.2 ± 41.1 μM (n = 3) in the cerebral systems. The method essentially offers a new method for the detection of Mg(2+) in the cerebral system.