Liver cancer is a leading cause of death worldwide, and hepatocellular carcinoma (HCC) is the most frequent primary liver tumour, followed by cholangiocarcinoma. Notably, secondary tumours represent up to 90% of liver tumours. Chronic liver disease is a recognised risk factor for liver cancer development. Up to 90% of the patients with HCC and about 20% of those with cholangiocarcinoma have an underlying liver alteration. The gut microbiota-liver axis represents the bidirectional relationship between gut microbiota, its metabolites and the liver through the portal flow. The interplay between the immune system and gut microbiota is also well-known. Although primarily resulting from experiments in animal models and on HCC, growing evidence suggests a causal role for the gut microbiota in the development and progression of chronic liver pathologies and liver tumours. Despite the curative intent of “traditional” treatments, tumour recurrence remains high. Therefore, microbiota modulation is an appealing therapeutic target for liver cancer prevention and treatment. Furthermore, microbiota could represent a non-invasive biomarker for early liver cancer diagnosis. This review summarises the potential role of the microbiota and immune system in primary and secondary liver cancer development, focusing on the potential therapeutic implications.