Abstract A new spectrophotometric method has been developed in this paper to determine melamine in milk by applying rank annihilation factor analysis (RAFA) based on pH gradual change-UV spectral data (pH-spectra). In the proposed method, the spectra of the sample solutions at different pH data points were recorded and the pH-spectra bilinear data matrix was generated. Based on these data, the RAFA was then applied to calculate the concentration of melamine in milk. The experiments have been conducted and the results were satisfactory. Under the optimised conditions, linearity of the proposed method was in the range of 0.04–4.0μgmL−1 for calibration samples, and 0.04–3.5μgmL−1 for the mixed solutions of melamine with the background milk components. The detection limit (DL) was 12ngmL−1. The relative predictive error (RPEs) and root mean square error of prediction (RMSEP) of applying RAFA were 0.91% and 0.0151, respectively.