It is particularly important to develop effective and specific detection methods for harmful metal ions such as the silver ion (Ag+) and mercury ion (Hg2+). In this article, a new near‐infrared (NIR) fluorescent probe (N‐FP) based on intramolecular charge transfer (ICT) effect was designed and synthesised, which exhibited the characteristics of large Stokes shift (163 nm) and excellent stability. Addition of Ag+ or Hg2+ to the N‐FP solution in ethanol/water (9:1, v/v) caused remarkable enhancement of fluorescence emission at 661 nm, bathochromic shift of ultraviolet‐visible absorption wavelength, and colour change from orange to red or purple. While adding other metal ions including Li+, Na+, K+, Ag+, Cu2+, Fe2+, Zn2+, Co2+, Ni2+, Mn2+, Sr2+, Ca2+, Mg2+, Al3+, Cr3+ and Fe3+ did not bring about substantial spectral and colour change. The detection limit of the N‐FP for Ag+ and Hg2+ was calculated to be 1.1 and 0.72 μM, respectively. The N‐FP could be used to recognise Ag+ and Hg2+ in a wide pH range of 1–10. The sensing mechanism was proposed and demonstrated by proton nuclear magnetic resonance (1H‐NMR), high‐performance liquid chromatography (HPLC) and mass spectrometry (MS) measurements