A new Mg2+-selective fluorescent probe P was synthesized and characterized. With optimal conditions, the proposed probe P showed good selectivity to Mg2+ compared to other common metal ions, and worked in a wide linear range of 5.0 × 10−7–6.0 × 10−6 M with a detection limit of 1.7 × 10−7 M Mg2+ in ethanol-water solution (9:1, v/v, 20 mM HEPES, pH = 10.0).