Stepwise synthesis of aminotetrazole functionalized MgO–SiO2 (MSNT) nanocomposites has been achieved by a simple wet chemical method. The as-synthesized nanomaterial is investigated for the removal of dye and the detection of heavy metal ions from the aqueous solutions. The structural, textural, and morphological characteristics of the nanocomposites are characterized by P-XRD, FT-IR, solid-state NMR, TGA, BET N2 isotherm, FE-SEM, and TEM techniques. The dye adsorption studies reveal that the material selectively and rapidly adsorbs the acid fuchsin (AF) dye (78% color removal within 2 min) with high adsorption capacity (775.6 mg/g) and good recyclability. The adsorption isotherm and kinetic studies indicate that the dye adsorption takes place by the Freundlich isotherm and pseudo-second-order kinetic model. The material has been used to modify the glassy carbon electrode (GCE) for the detection of Pb(II) and Hg(II) ions by square wave anodic stripping voltammetry (SWASV), which shows excellent sensitivity (≈75 μA·μM–1·cm–2 and 40 μA·μM–1·cm–2) and low detection limit (0.019 μM and 0.041 μM) for Pb(II) and Hg(II) ions, respectively. The practical applicability of the material for heavy metal ion detection has also been ascertained by stability, reproducibility, interference, simultaneous detection, and real-time sample studies.