A highly fluorescent chemosensor based on 1,8-naphthyridine with high sensitivity and selectivity toward Ni(2+)/Cu(2+) over other cations both in aqueous solution over a wide pH range (4-10) and in cellular environments was developed. Counteranions such as acetate, sulfate, nitrate, and perchlorate have no influence on the detection of such metal ions. Ethylenediamine showed high selectivity toward the in situ-prepared Cu(2+) complex over the Ni(2+) complex, which can be applied to distinguish Ni(2+) and Cu(2+). The Ni(2+)-induced fluorescence on-off mechanism was revealed to be mediated by intramolecular charge transfer from the metal to the ligand, while that by Cu(2+) involves intramolecular charge transfer from the ligand to the metal, as confirmed by picosecond time-resolved fluorescence spectroscopy and time-dependent density functional theory calculations.