Graphite carbon nitride nanosheets (g-C3N4NSs) exhibite excellent electrochemiluminescence (ECL) performance and good film-forming properties. In this paper, g-C3N4NSs were used as an ECL material to be fixed on a glassy carbon electrode(GCE). A molecularly imprinted polymer (MIP) was prepared by molecular self-assembly with chlorpyrifos (CPF) as template molecule and methacrylic acid (MAA) as functional monomer. The polymer was then introduced into g-C3N4NSs modified electrode to construct a MIP-ECL sensor. After removing the template molecule, the sensor can specifically recognize CPF. Based on the specific recognition and quenching effect of CPF on the ECL signal of g-C3N4NSs, the high sensitive and selective detection of CPF was achieved. The sensor shows a linear response to CPF in range of 1.0×10-8-1.0×10-4 mol·L-1 and limit of detection (LOD) of 5.0 nmol·L-1. It was used to detect CPF residues in vegetables and the results were satisfactory.