Ambient PM2.5 has been associated with preterm birth (PTB); however, the mechanism has not been elucidated. A birth cohort study, pregnant mouse models, and HTR-8/SVneo cells were conducted to achieve the study objectives. We observed 9833 (6.6 %) PTBs among the participants, the median gestational week (GW) is 39.25. Cox model and accelerated failure time model revealed that each 10 μg/m3 increase in PM2.5 was associated with an elevated risk of PTB during the entirety of pregnancy (hazard ratio and 95 % confidence interval [HR 95 %CI) was 1.15 (1.07, 1.24)], and reduced gestational week by 1.6 % (ETR: 0.984, 95 % CI: 0.976-0.992). In animal model, we found a shorter gestational day in PM2.5 exposure group than filtered air group, miRNA-sequencing analysis revealed that miRNA-21a-5p was significantly down-regulated in the PM2.5 group (p < 0.05), GO and KEGG analysis indicated that TLR4/NF-κB was involved in the process of PM2.5 shortening pregnancy. Western blot showed that PM2.5 exposure increased TLR4, NF-κB, and NLRP3 inflammasome in vivo and vitro. BAY11-7082 and miRNA-21 mimic inhibited the PM2.5-activated TLR4/NF-κB signaling pathway and NLRP3 inflammasome. This study provides evidence on the potential molecular mechanism of miRNA-21-5p/TLR4/NF-κB signaling pathway in PM2.5-induced inflammatory response leading to PTB through NLRP3 inflammasome.