Metabolic production of acetyl coenzyme A (acetyl-CoA) is linked to histone acetylation and gene regulation, but the precise mechanisms of this process are largely unknown. Here we show that the metabolic enzyme acetyl-CoA synthetase 2 (ACSS2) directly regulates histone acetylation in neurons and spatial memory in mammals. In a neuronal cell culture model, ACSS2 increases in the nuclei of differentiating neurons and localizes to upregulated neuronal genes near sites of elevated histone acetylation. A decrease in ACSS2 lowers nuclear acetyl-CoA levels, histone acetylation, and responsive expression of the cohort of neuronal genes. In adult mice, attenuation of hippocampal ACSS2 expression impairs long-term spatial memory, a cognitive process that relies on histone acetylation. A decrease in ACSS2 in the hippocampus also leads to defective upregulation of memory-related neuronal genes that are pre-bound by ACSS2. These results reveal a connection between cellular metabolism, gene regulation, and neural plasticity and establish a link between acetyl-CoA generation 'on-site' at chromatin for histone acetylation and the transcription of key neuronal genes.