The inhibition of fungal contamination of food by natural plant essential oils is receiving widespread attention. In this study, 1 mu L/mL p-anisaldehyde showed remarkable antifungal ability against Aspergillus flavus spore germination and mycelium growth. Experiments of peanut seeds infection showed that 4 mu L/mL p-anisaldehyde inhibited the development of A. flavus spores on peanuts by 95.5% and the production of aflatoxin B1 production by 69.4%. Transcriptome analysis suggested that differentially expressed genes were primarily associated with spore growth, cell wall, cell membrane, oxidative stress, and energy metabolism. Physiological and biochemical experiments as well as scanning electron microscopy, fluorescence staining, and enzyme activity assay, further confirmed that p-anisaldehyde destroyed the cell wall, permeability, and ergosterol biosynthesis of the cell membrane and led to decreased mitochondrial membrane potential and accumulated reactive oxygen species. This study provided new knowledge on the antifungal activity of p-anisaldehyde and its mechanism of action, as well as theoretical support for p-anisaldehyde as a possible antifungal agent for the control of A. flavus contamination of food crops.