The gut microbiota significantly impacts antitumour immunity and alters the effectiveness of cancer immunotherapy. Immunotherapies, notably inhibitors of immune checkpoints that target programmed death 1 (PD-1) and cytotoxic T lymphocyte-associated antigen 4 (CTLA-4), have profoundly changed the way advanced and metastatic cancer is treated and dramatically improved overall and progression-free survival. However, the underlying molecular mechanisms by which the gut microbiota affects antitumour immunity and the efficacy of cancer immunotherapy remain elusive. In this review, we summarize the latest knowledge supporting the associations among the gut microbiota, antitumour immunity, and immunotherapy. The potential molecular mechanisms underlying these associations are explained in terms of four aspects.