Background We aimed to assess differences in intestinal microflora between patients with operable hepatitis B virus-related hepatocellular carcinoma (HBV-HCC) with microvascular invasion (MVI) and those without MVI. Additionally, we investigated the potential of the microbiome as a non-invasive biomarker for patients with MVI. Methods We analyzed the preoperative gut microbiomes (GMs) of two groups, the MVI (n = 46) and non-MVI (n = 56) groups, using 16S ribosomal RNA gene sequencing data. At the operational taxonomic unit level, we employed random forest models to predict MVI risk and validated the results in independent validation cohorts [MVI group (n = 17) and non-MVI group (n = 15)]. Results β diversity analysis, utilizing weighted UniFrac distances, revealed a significant difference between the MVI and non-MVI groups, as indicated by non-metric multidimensional scaling and principal coordinate analysis. We also observed a significant correlation between the characteristic intestinal microbial communities at the genus level and their main functions. Nine optimal microbial markers were identified, with an area under the curve of 79.76% between 46 MVI and 56 non-MVI samples and 79.80% in the independent verification group. Conclusion This pioneering analysis of the GM in patients with operable HBV-HCC with and without MVI opens new avenues for treating HBV-HCC with MVI. We successfully established a diagnostic model and independently verified microbial markers for patients with MVI. As preoperative targeted biomarkers, GM holds potential as a non-invasive tool for patients with HBV-HCC with MVI.