Melatonin is normally consumed to regulate the body’s biological cycle. However it also has therapeutic properties, such as anti-tumor, anti-aging and protects the immune system. There are some reports on the presence of melatonin in edible kernels such as walnuts, but the extraction of melatonin from pistachio kernels is reported here for the first time. For this, the methanolic extract of pistachio kernels was exposed to gas chromatography/mass spectrometry analysis which confirmed the presence of melatonin. A fluorescence-based method was applied for the determination of melatonin in different extracts. When excited at λ=275nm, the fluorescence emission intensity of melatonin was measured at λ=366nm. Ultrasound-assisted solid–liquid extraction was used for the extraction of melatonin from pistachio kernels prior to fluorimetric determination. To achieve the highest extraction recovery, the main parameters affecting the extraction efficiency such as extracting solvent type and volume, temperature, sonication time and pH were evaluated. Under the optimized conditions, a linear dependence of fluorescence intensity on melatonin concentration was observed in the range of 0.0040–0.160μgmL−1, with a detection limit of 0.0036μgmL−1. This method was applied successfully for measuring and comparing the melatonin content in the kernels of four different varieties of Pistacia including Ahmad Aghaei, Akbari, Kalle Qouchi and Fandoghi. In addition, the results obtained were compared with those obtained using GC/MS. A good agreement was observed indicating the reliability of the proposed method.