Trace amounts of Hg2+ are detected by using a microcantilever coated with gold. The microcantilever undergoes bending due to accumulation of Hg2+ on the gold surface. It is found that a concentration of 10(-11) M Hg2+ can be detected using this technology. Other cations, such as K+, Na+, Pb2+, Zn2+, Ni2, Cd2+, Cu2+, and Ca2+ have little or no effect on the deflection of the cantilever. The selectivity of the Hg2+ sensor could be improved by coating the gold surface of microcantilever with a self-assembled monolayer of a long-chain thiol compound.