An analytical ultrasound-assisted extraction (UAE) technique has been optimized and validated for the extraction of melatonin from rice grains. A Box–Behnken design in conjunction with a response surface methodology based on six factors and three levels was used to evaluate the effects of the studied factors prior to optimizing the UAE conditions. The significant (p < 0.05) response surface models with high coefficients of determination were fitted to the experimental data. Solvent composition and extraction temperature were found to have very significant effects on the response value (p < 0.005). The optimal UAE conditions were as follows: extraction time of 10 min, ultrasound amplitude of 30%, cycle of 0.2 s−1, extraction temperature of 40 °C, 50% methanol in water as the extraction solvent at pH 3.5 and a solvent/solid ratio 2.5:1. The method validation ensured right values for linearity, LOD, LOQ, precision and recovery. Furthermore, the method was successfully applied in the analysis of a number of rice samples throughout the rice production process. Hence, it was demonstrated that this particular UAE method is an interesting tool for the determination of melatonin in rice grain samples.