The gut microbiota (GM) influences the occurrence and progression of lung cancer (LC), with potential involvement of immune cells (IC). We aimed to investigate the causal impact of GM on LC and identify potential immune cell mediators. The utilized data for the Genome-Wide Association Studies (GWAS) were summarized as follows: gut microbiota data from the Dutch Microbiome Project (DMP) (N = 7,738), lung cancer data from the Transdisciplinary Research in Cancer of the Lung (TRICL) and International Lung Cancer Consortium (ILCCO) (Ncase = 29,266, Ncontrol = 56,450) included four types of cancer: NSCLC, LUAD, LUSC, and SCLC, and immune cell data from European populations (N = 3,757). We employed bi-directional two-sample univariable Mendelian randomization (UVMR), multivariable Mendelian randomization (MVMR), and mediation analysis to assess the causal relationship between GM and LC and potential immune cell mediators. Bi-directional UVMR analysis revealed that 24 gut microbiota species can affect LC, while LC can affect the abundance of 17 gut microbiota species. Mediation analysis demonstrated that six immune cells mediated the causal relationships of seven gut microbiota species on LC: "CCR7 on naive CD8+ T cell" mediated the causal relationship between s_Alistipes_putredinis and LUAD, with a mediation proportion of 9.5% and P = 0.018; "IgD- CD27- B cell %lymphocyte" mediated the causal relationships between g_Gordonibacter and s_Gordonibacter_pamelaeae with LUSC, with mediation proportions of 11.8% and 11.9%, respectively and P = 0.029; "CD20- CD38- B cell %lymphocyte" mediated the causal relationship between s_Bacteroides_clarus and SCLC, with a mediation proportion of 13.8% and P = 0.005; "CD20 on IgD+ CD38- unswitched memory B cell" mediated the causal relationship between s_Streptococcus_thermophilus and SCLC, with a mediation proportion of 14.1% and P = 0.023; "HLA DR on CD14- CD16+ monocyte" mediated the causal relationship between s_Bifidobacterium_bifidum and SCLC, with a mediation proportion of 8.7% and P = 0.012; "CD45 on Granulocytic Myeloid-Derived Suppressor Cells" mediated the causal relationship between f_Lactobacillaceae and SCLC, with a mediation proportion of 4.0% and P = 0.021. This Mendelian randomization study identified several specific gut microbiotas that exhibit causal relationships with lung cancer and potentially mediate immune cells.