The one-pot reaction of β-lactam carbenes with 2-pyridyl isonitriles followed by an acidic hydrolysis was reported, which produced 2-carbonyl-3-(pyridylamino)imidazo[1,2-a]pyridines in moderate to good yields. Among the resulting novel imidazo[1,2-a]pyridine derivatives, 1-(6-chloro-3-(5-chloropyridin-2-ylamino)imidazo[1,2-a]pyridin-2-yl)-2-ethylbutan-1-one was demonstrated to be an efficient fluorescent probe for mercury ion both in acetonitrile and in buffered aqueous solution.