To investigate the relationship between the gut microbiome and the response to anti-PD-1-based combination therapy in unresectable hepatocellular carcinoma (HCC). We aimed to identify potential non-invasive biomarkers and new strategies to modulate immunotherapy in HCC. In this study, fresh stool samples and clinical data were collected from unresectable HCC patients treated with anti-PD-1-based combination therapy at the Cancer Hospital of the Chinese Academy of Medical Sciences between January 2020 and December 2021. The patients were divided into two groups based on their response to treatment: the treatment responder group (R group) and the treatment non-responder group (NR group). The composition and diversity of the gut microbiome were bioinformatically analyzed by using the Whole Genome Shotgun strategy, including taxonomic composition analysis, Alpha diversity analysis, Beta diversity analysis, and differentially enriched bacterial taxa analysis. Differentially enriched bacterial taxa between R and NR groups were identified based on the magnitude of the linear discriminant analysis effect size (LEfSe) and analyzed for their impact on the survival of the patient. A total of 45 eligible patients with unresectable HCC treated with anti-PD-1-based combination therapy participated in this study. The gut microbiological composition and Alpha diversity of patients were not statistically different, but there was a statistically significant difference in Beta diversity between the R and NR groups. (PERMANOVA tests, P = 0.006). We further identified 56 enriched bacterial taxa in the R group and 44 enriched bacterial taxa in the NR group based on the LEfSe analysis (LDA >2.66, P< 0.05). Patients with a high abundance of Collinsella genus, Ruminococcus_AM4211, and Ruminococcus_AF25_28AC had a longer median PFS and median OS compared to those with low abundance (P < 0.05). On the contrary, the median PFS and OS of patients with a high abundance of Bacteroides_AF20_13LB and Veillonella_atypica were significantly shorter than those of patients with low abundance (P < 0.05). The multivariate analysis showed that the abundance of Bacteroides_AF20_13LB and Ruminococcus_ AF25_28AC was independent related factors for PFS, and the abundance of Bacteroides_AF20_13LB was an independent related factor of OS. The enrichment of specific gut microbiota affected clinical efficacy and survival benefits in HCC treated with anti-PD-1 therapy and may be a promising non-invasive gut microbial biomarker and a new strategy for modulating immunotherapy in HCC.