Diets rich in sugar and saturated fat are associated with cognitive impairments in both humans and rodents with several potential mechanisms proposed. To test the involvement of diet-induced pro-inflammatory signaling, we exposed rats to a high-fat, high-sugar cafeteria diet, and administered the anti-inflammatory antibiotic minocycline. In the first experiment minocycline was coadministered across the diet, then in a second, independent cohort it was introduced following 4 weeks of cafeteria diet. Cafeteria diet impaired novel place recognition memory throughout the study. Minocycline not only prevented impairment in spatial recognition memory but also reversed impairment established in rats following 4 weeks cafeteria diet. Further, minocycline normalized diet-induced increases in hippocampal pro-inflammatory gene expression. No effects of minocycline were seen on adiposity or dietary intake across the experiments. Cafeteria diet and minocycline treatment significantly altered microbiome composition. The relative abundance of Desulfovibrio_OTU31, uniquely enriched in vehicle-treated cafeteria-fed rats, negatively and significantly correlated with spatial recognition memory. We developed a statistical model that accurately predicts spatial recognition memory based on Desulfovibrio_OTU31 relative abundance and fat mass. Thus, our results show that minocycline prevents and reverses a dietary-induced diet impairment in spatial recognition memory, and that spatial recognition performance is best predicted by changes in body composition and Desulfovibrio_OTU31, rather than changes in pro-inflammatory gene expression.