As a condiment with extensive nutritional value, chili is easy to be contaminated by Aspergillus flavus (A. flavus) during field, transportation, and storage. This study aimed to solve the contamination of dried red chili caused by A. flavus by inhibiting the growth of A. flavus and detoxifying aflatoxin B1 (AFB1). In this study, Bacillus subtilis E11 (B. subtilis) screened from 63 candidate antagonistic bacteria exhibited the strongest antifungal ability, which could not only inhibit 64.27% of A. flavus but could also remove 81.34% of AFB1 at 24 h. Notably, scanning electron microscopy (SEM) showed that B. subtilis E11 cells could resist a higher concentration of AFB1, and the fermentation supernatant of B. subtilis E11 could deform the mycelia of A. flavus. After 10 days of coculture with B. subtilis E11 on dried red chili inoculated with A. flavus, the mycelia of A. flavus were almost completely inhibited, and the yield of AFB1 was significantly reduced. Our study first concentrated on the use of B. subtilis as a biocontrol agent for dried red chili, which could not only enrich the resources of microbial strains for controlling A. flavus but also could provide theoretical guidance to prolong the shelf life of dried red chili.