Brain metastasis (BM) is associated with high mortality in patients with non-small cell lung cancer (NSCLC). Alterations in the gut microbiota have been implicated in modulation of brain disorders through the gut-brain-axis (GBA). However, the underlying mechanism by which the gut microbiota affects the development of BM in NSCLC remains largely unknown. In patients, we identified 16 genera of differential bacteria positively or negatively correlated with BM in NSCLC patients, as represented by Klebsiella, unclassified_f_Enterobacteriaceae and Alistipes by 16S rRNA gene sequencing. In addition, untargeted metabolomics (LC-MS/MS and GC/MS) identified 76 metabolites, that were associated with BM. The combination of intestinimonas and spermine was considered a potential marker for the diagnosis of BM in NSCLC. Moreover, the plasma metabolite spermine enhanced BM by promoting M2 polarization of microglia via activation of the signal transducer and activator of transcription 3 (STAT3) signaling pathway in vivo and in vitro, suppressing innate immune function, which in turn promoted tumor progression. Overall, our study demonstrated the composition of both the gut microbiota and metabolites changed significantly between groups, and revealed that metabolite spermine promotes BM by skewing the polarity of M2 microglia by activating STAT3 signals. Our results provide a novel perspective regarding host-gut microbiota interplay in BM of NSCLC and highlight a potential risk of spermine in promoting BM.