Mercury(II) ions (Hg 2+ ) and silver ions (Ag + ) are two of the most hazardous pollutants causing serious damage to human health. Here, we constructed surface-enhanced Raman scattering (SERS)-active nanofibers covered with 4-mercaptopyridine (4-Mpy)-modified gold nanoparticles to detect Hg 2+ and Ag + . Experimental evidence suggests that the observed spectral changes originate from the combined effect of (i) the coordination between the nitrogen on 4-Mpy and the metal ions and (ii) the 4-Mpy molecular orientation (from flatter to more perpendicular with respect to the metal surface). The relative intensity of a pair of characteristic Raman peaks (at ∼428 and ∼708 cm −1 ) was used to quantify the metal ion concentration, greatly increasing the reproducibility of the measurement compared to signal-on or signal-off detection based on a single SERS peak. The detection limit of this method for Hg 2+ is lower than that for the Ag + (5 vs 100 nM), which can be explained by the stronger interaction energy between Hg 2+ and N compared to Ag + and N, as demonstrated by density functional theory calculations. The Hg 2+ and Ag + ions can be masked by adding ethylenediaminetetraacetate and Cl − , respectively, to the Hg 2+ and Ag + samples. The good sensitivity, high reproducibility, and excellent selectivity of these nanosensors were also demonstrated. Furthermore, detection of Hg 2+ in living breast cancer cells at the subcellular level is possible, thanks to the nanometric size of the herein described SERS nanosensors, allowing high spatial resolution and minimal cell damage.