Short-term exposure to high-energy diets impairs memory but there are limited data regarding the relative contributions of fat and sugar to these deficits or the mechanisms responsible. Here, we investigated how these different macronutrients affect memory, neuroinflammation and neuroplasticity markers and the gut microbiota in the short-term. Rats were fed matched purified diets for 2 weeks; Control, Sugar, Saturated Fatty Acid (SFA) or Polyunsaturated Fatty Acid (PUFA), which varied only in the percentage of energy available from sugar and the amount and type of fat. Memory was assessed after 8-9 days and rats were culled after 12-13 days exposure. The expression of genes related to inflammation and plasticity were determined via reverse transcription polymerase chain reaction (RT-PCR) and the fecal microbiota was quantified via high-throughput sequencing of the 16S ribosomal RNA. Weight gain and energy intake were comparable across the diets. Rats consuming the SFA and Sugar diets were impaired on hippocampal-dependent place recognition memory compared to Controls and PUFA rats. All rats performed comparably on the perirhinal-dependent object recognition task. Hippocampal and hypothalamic inflammatory and neuroplasticity genes were not substantially affected, but each of the diets significantly altered the microbial composition in distinct ways. Specifically, the relative abundance of 89 taxa differed between groups with the majority of changes accounted for by the Clostridiales order and within that, Lachnospiraceae and Ruminococcaceae. These taxa showed a range of macronutrient specific correlations with place memory. In addition, Distance based Linear Models found relationships between memory, a cluster of hippocampal inflammation-related genes and gut microbiota composition. In conclusion, our study shows that even in the short-term the macronutrient profile of the diet is crucial for diet-induced memory deficits and suggests a possible link between diet, gut microbiota and hippocampal inflammatory genes. Longer term studies are warranted.