The potential of the gut microbiome as a driver of individual cognitive differences in natural populations of animals remains unexplored. Here, using metagenomic sequencing of individual bumblebee hindguts, we find a positive correlation between the abundance of Lactobacillus Firm-5 cluster and memory retention on a visual discrimination task. Supplementation with the Firm-5 species Lactobacillus apis, but not other non-Firm-5 bacterial species, enhances bees’ memory. Untargeted metabolomics after L. apis supplementation show increased LPA (14:0) glycerophospholipid in the haemolymph. Oral administration of the LPA increases long-term memory significantly. Based on our findings and metagenomic/metabolomic analyses, we propose a molecular pathway for this gut-brain interaction. Our results provide insights into proximate and ultimate causes of cognitive differences in natural bumblebee populations.