Maternal obesity and perinatal high‐fat diets are known to affect cognitive development. We examined the effects of late prenatal and/or early postnatal exposure to a Western‐type diet, high in both fat and refined sugar, on the cognition of pigs (Sus scrofa) in the absence of obesity. Thirty‐six sows and their offspring were assigned to 1 of 4 treatments in a 2 × 2 factorial arrangement, with 8 wk prenatal and 8 wk postnatal exposure to a Western diet (enriched in fat, sucrose, and cholesterol) or control diets as factors. Compared to controls, piglets exposed to the prenatal Western diet showed enhanced working and reference memory during the acquisition and reversal phases of a spatial hole‐board task. Mothers fed the prenatal Western diet had higher prepartum blood cholesterol and free fatty acid levels. Postnatal exposure to the Western diet did not affect piglet cognitive performance, but it did increase postpartum maternal and postweaning piglet cholesterol levels. The Western diet had no effect on maternal or offspring insulin sensitivity or leptin levels. In conclusion, a prenatal Western diet improved memory function in pigs, which was paired with changes in prepartum maternal blood cholesterol levels. These findings highlight the key role of late fetal nutrition for long‐term programming of cognition.—Clouard, C., Kemp, B., Val‐Laillet, D., Gerrits, W. J. J., Bartels, A. C., Bolhuis, J. E. Prenatal, but not early postnatal, exposure to a Western diet improves spatial memory of pigs later in life and is paired with changes in maternal prepartum blood lipid levels. FASEB J. 30, 2466‐2475 (2016). http://www.fasebj.org