Molecularly imprinted polymer (MIP) films of melamine were prepared by photopolymerization of vinylic monomers on diazonium-modified gold electrodes. The gold-grafted MIPs are specific and selective for melamine in either organic or aqueous media. The interferent molecules cyromazine and cyanuric acid were not recog-nized by the MIPs. The limit of detection was as low as 1.75 x 10(-12) molL(-1) at S/N=3. Efficiency of melamine re-binding is related to the solubility parameter of the organic solvent or pH and ionic strength of the aqueous medium. It is concluded that diazonium salts permit to design robust electrochemical MIP sensors.