A surface-enhanced Raman scattering (SERS) strategy based on 4-mercaptopyridine (MPY)-modified gold nanoparticles (AuNPs) was developed for the rapid and sensitive detection of melamine in milk powder. The SERS measurement of melamine strongly relied on the "hotspot" effect, in which AuNPs immediately aggregated upon the addition of melamine, leading to significantly enhanced Raman intensity of the reporter molecule MPY and a color change for the solution from red to blue-gray. The limit of detection based on a signal to noise of 3 (S/N = 3) was found to be as low as 0.1 ppb of melamine, with an excellent linearity of 0.5-100 ppb, demonstrating a higher sensitivity and a wider quantitation range than direct SERS sensing methods based on enhanced substrate. An impressive specificity for melamine detection over various common metal ions and excipients in dairy products, even at concentrations of 100-fold higher than melamine, was achieved. Good recoveries of 88.5% and 111.7% were obtained from milk samples spiked to 20 and 100 ppb levels, respectively. The proposed method is potentially applicable for the rapid in situ determination of melamine in complex matrices.