Aflatoxin contamination poses a serious problem for the pistachio industry as aflatoxin B1 (AFB1), the most harmful aflatoxin, can be produced by some species of the Aspergillus and Penicillium. Like any other living organism, Aspergillus flavus (A. flavus) releases specific volatile organic compounds (VOCs) as a result of its metabolic reactions. In this study, we extracted and analyzed the VOCs produced by toxigenic A. flavus using solid-phase microextraction (SPME) in combination with gas chromatography-mass spectroscopy (GC-MS). The study was conducted on culture media and pistachio inoculated samples over a period of 16 days to observe the production of VOCs and aflatoxin over time. Various chemicals from different classes (such as organic acids, alcohols, ketones, and hydrocarbons) were detected during the growth of A. flavus on pistachios. Agglomerative hierarchical clustering was performed on the GC-MS spectra to identify VOCs corresponding to AFB1. We have identified ten VOCs with the potential to function as biomarkers for monitoring the growth of A. flavus NRRL 3357 on in-shell pistachios, and α,β-dimethylbenzenepropanoic acid was identified as the primary early marker for detecting A. flavus infection in pistachios.